Time for action – creating the level selection

A new scene and a single script will serve us well in managing our level selection:

  1. This last section begins by saving your current scene and hitting Ctrl + N to create a new one, named LevelSelect.
  2. For this scene, we need to create a single, short script also named LevelSelect.
  3. The first and only variable defines the size of the buttons that will appear on screen.
    public int buttonSize = 100;
  4. 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. A Rect variable is created and initialized to the buttonSize. 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.