Hey all, basically I already searched on the forum but I need to fix what I found for my needings…my problem is this. I have a game of 10 levels. At the end of each level a button spawn and clickin on it you go into the next level. I want everytime the player click this button the engine randomly choose trough all the levels not repeating the level already played. I found this but I don’t know exactly how to use it…someone can clarify to me?
using UnityEngine;
using System.Collections.Generic;
public static class SceneManager
{
private const int kNumScenes = 5;
private static List<int> s_SceneList = null;
public static bool NextScene ()
{
if (s_SceneList == null)
{
s_SceneList = new List<int> ();
for (int i = 1; i <= kNumScenes; i++)
{
s_SceneList.Add (i);
}
for (int i = 0; i < s_SceneList.Count; i++)
{
int index = Random.Range (0, s_SceneList.Count);
s_SceneList.Add (s_SceneList [index]);
s_SceneList.RemoveAt (index);
}
}
if (s_SceneList.Count < 1)
{
return false;
}
int scene = s_SceneList [0];
s_SceneList.RemoveAt (0);
Application.LoadLevel (scene);
return true;
}
}
plus considering is a old answer maybe there are new methods now to do what I’m looking for…thank you very much for your patience and your time