Hi, I made random levels that shouldn’t repeat themselves after they are loaded. When the player fails and presses the restart button the scenes that were already in use don’t repeat themselves again.
private static List<int> remainingScenes = new List<int>() { 1, 2, 3, 4, };
public void Update()
{
if (MainCamera.position.y >= 10.02)
{
startTimer = true;
}
if (startTimer)
{
timer -= 1.0f * Time.deltaTime;
if (timer <= 0.0f && remainingScenes.Count > 0)
{
startTimer = false;
int sceneIndex = Random.Range(0, remainingScenes.Count);
int scene = remainingScenes[sceneIndex];
remainingScenes.RemoveAt(sceneIndex);
SceneManager.LoadScene(scene);
}
}
}
Thank you 
private static List remainingScenes;
private void Awake()
{
if( remainingScenes == null )
RebuildRemainingScenes();
}
public void Update()
{
if (MainCamera.position.y >= 10.02)
{
startTimer = true;
}
if (startTimer)
{
timer -= 1.0f * Time.deltaTime;
if (timer <= 0.0f && remainingScenes.Count > 0)
{
startTimer = false;
LoadRemainingScene();
}
}
}
private void LoadRemainingScene()
{
int sceneIndex = Random.Range(0, remainingScenes.Count);
int scene = remainingScenes[sceneIndex];
remainingScenes.RemoveAt(sceneIndex);
SceneManager.LoadScene(scene);
}
// Call this function when the user restarts the game
public void RebuildRemainingScenes()
{
if( remainingScenes == null )
remainingScenes = new List<int>();
remainingScenes.Clear();
remainingScenes.AddRange( new int[]{ 1, 2, 3, 4, } );
}
Thank you.
I will give you an example what is my problem: I started the game I went through the steps: 1,3,4 and was disqualified in step 5, I press the button that will start all over again and it returns to scene 1 (I made an order that it will always return to scene 1). So I go through Stage 1 and it’s there in Stage 2. After I go through this scene, I do not get into any scene because all the other scenes are loaded and deleted.
Hope you understand.
BTW thank you for the help.