SOLVED REPEATING SCENE

Hi I was running this script. But I don’t want the next scene always repeating. I mean when I clicks the button the scene will go to the next scene and don’t repeat same scene. However, this script always repeating same scene and play random scene

private List<int> scenarios;

private static SceneAdvance instance;

private SceneAdvance()
{
    scenarios = new List<int> { 1, 2, 3, 4 };
}

public static SceneAdvance Instance
{
    get
    {
        if (instance == null)
        {
            instance = new SceneAdvance();
        }
             return instance;
    }
}

public void LoadNextScene()
{
    if (scenarios.Count == 0)
        return;
    int randomIndex = UnityEngine.Random.Range(0, scenarios.Count);
    int currentScenario = scenarios[randomIndex];
    scenarios.RemoveAt(randomIndex);
    SceneManager.LoadScene(currentScenario);
}

What are you trying to do?
If you want to load a random scene just use sceneCount, and store the scenes you already visited or have a static list of Scenes

Hey thankyou for reply. Act I’ve find out that this code didn’t match with my project since this code make scene be display by random.
However, what I suppose want to do is even user clicks random button but the scene still display by list/order/sequence.

ex:
User A > clicks button 6 > display scene 1 > back > clicks button 5 > display scene 2
User B ? clicks Button 3 > display scene 1 > back > clicks button 1 > display scene 2

Do you think this possible?

Owh, that’s not that hard. So any button just takes you to the next scene?
Just make a script.
In here store a static int called NextScene, make this 1 as default (scene 0 is the one you start normally)
If someone pressed a button fire a function that does SceneManager.LoadScene(NextScene); and then increase the int by 1.
You can get the total number of scenes to check if it is a valid scene