Mobile World Level Selection

I would love to see your implementation of a level selection screen for a mobile game. Many mobile games utilize this. Something similar to old Super Mario World, where there is a graphical world which contains level entrances. Levels are revealed as you progress through the world.

I’ll see what I can work up this weekend. It’s actually something I want to do in my JRPG I’m working on as well.

I’m not going to walk through the details of doing a graphical implementation of this, as it’s a matter of puttting a button for each level on a map… I think the important thing to look at is deciding if those buttons appear in the first place, based on level.

I’m assuming this is a case where the scenes available are based on the player level, but any metric you wish to use will work… it could be a number of stars collected or any other thing you can think of. We’re going to call this “level” for now.

[RequireComponent(typeof(Button))
public class SceneSelector:MonoBehavior
{
    [SerializeField] int levelRequired=1;
    [SerializeField] int sceneIndex = 1;

    Button button;    

    void Awake()
    {
         button = GetComponent<Button>();
         button.interactable=false;
    }

    public void SetConditionBasedOnLevel(int level)
    {
          button.interactable = level>=levelRequired;
    }

    public void LoadScene()
    {
          SceneManager.LoadScene(sceneToLoad);
     }
}

Put this on each button representing a scene you wish to load, and set the button to call the SceneSelector.LoadScene. Fill in the data for level required and scene to load (the index of the scene in the build menu)

When the Main Menu loads, it needs to get the level, and then run this little snippet of code

foreach(SceneSelector selector in FindObjectsOfType<SceneSelector>())
{
     selector.SetConditionBasedOnLevel(level);
}

Now any buttons that are higher than the level will be disabled, and onliy buttons low enough for the current level will load.

1 Like

Privacy & Terms