Subtracting current scene from string?

I am trying to make a warioware clone essentially. I have it set up currently with a few minigames. I am trying to get it so that you can play through all the minigames without repeating a scene. Im new to unity so my knowledge is still very limited. First i have put everything in a string so that i can just call up on it at the end of each minigame. I was wondering if there was some way to use GetActiveScene(); to remove the current scene from the string, or a similar process for the same result. I’ll post what i have if there is a better way to go about doing it please let me know always excited to learn how to improve.

public class RandomScene : MonoBehaviour
{
    public int LevelRandomRange = Random.Range(0,3);
    void start()
    {
        if (Random.value < .5)
        {
            string[] NextLevel = new string[] { "MiniGame1_A", "MiniGame2", "MiniGame3" };
        }
        else
        {
            string[] NextLevel = new string[] { "MiniGame1_B", "MiniGame2", "MiniGame3" };
        }
    }
}

// Application.LoadLevel(NextLevel[LevelRandomRange]);
1 Like

Use a list instead because it has a Remove function which will allow you to remove the string unlike an array. Arrays are fixed size. Something along the lines of:

List<string> nextLevel = new List<string>()
{
    "String One",
    "String Two"
};

nextLevel.Remove(SceneManager.GetActiveScene().name);

Should be enough to put you on the right path.

Should also be ‘Start’ just fyi.

Thank for the help i really appreciate it!

1 Like