Time for action – creating the level selection
A new scene and a single script will serve us well in managing our level selection:
- This last section begins by saving your current scene and hitting Ctrl + N to create a new one, named
LevelSelect
. - For this scene, we need to create a single, short script also named
LevelSelect
. - The first and only variable defines the size of the buttons that will appear on screen.
public int buttonSize = 100;
- The only function is the
OnGUI
function. This function starts with a loop. It will loop through three times for the three levels we should have created earlier. ARect
variable is created and initialized to thebuttonSize
. The x and y values are then set to position the buttons in a row, centered on the screen. Next, ...
Get Unity Android Game Development by Example Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.