After a while of not doing anything to my code, I have finally coded the locking and unlocking of scenes which I can use to element the other scenes. After which my next steps are to work on the Algebra scene.
How To Unlock a Button Via Player’s Balance.
Of course in coding there are multiple options; however this was the approach I took for creating a buy button in Unity.
Create 2 versions of the assets
For the first step you create the locked and unlocked sprite of the button for example this is what mine were.
From these images, I also exported a “pressed” version of each button to improve the user experience but this is completely optional. The main thing to notice is that there is a locked icon that will be displayed by default.
After creating buttons in unity you also need to create two more buttons to represent a Yes/No confirmation for buying after adding a text line this is what it looks like.
Unlocking the Scene
To unlock the scene you need to “hide” or set the locked object (button) to be inactive like this:
// declare button object public GameObject algebraLockedObj; //...other code inbetween... // set button object to be inactive AKA can't see/use algebraLockedObj.active = false;
You then do the inverse by setting the unlock button object to active so you can see and access the newly purchased scene! (Also make sure to save that the player has bought the scene by using something like playerprefs.
It was nice to get back to coding. I was definitely a little rusty because I forgot how the activate scripts at first but after about 30 minutes I was good to go. It was also a little scary to tackle this problem as I thought it would be a lot harder but after about an hour or two I had it done. Enjoy the video below of the
Goals for Next Time:
I just hope to get started on the Algebra scene. I am still unsure how I am going to do the UI and the problems as both will be different from the arithmetic scene.