Hello, I'm following a tutorial for setting up a scene manager that runs from a List (allowing for adding/removing scenes). In the video their code runs perfectly but for me, it keeps adding scenes. I distilled the code down to the smallest/simpliest example I could. What happens is Debug.Log() outputs an infinitely incrementing number....1,2,3,4....
Scene Script
public class InitController : MonoBehaviour
{
private void Start()
{
SceneController.instance.Add((int)SceneIndex.Splash);
SceneController.instance.Load();
}
}
Scene Manager Script
public class SceneController : MonoBehaviour
{
// Singleton
public static SceneController instance;
List<AsyncOperation> scenesActionList = new List<AsyncOperation>();
private void Awake()
{
if (instance == null)
{
instance = this;
}
else
{
Destroy(gameObject);
}
}
public void Add(int sceneIndex)
{
scenesActionList.Add(SceneManager.LoadSceneAsync(sceneIndex, LoadSceneMode.Additive));
}
public void Remove(int sceneIndex)
{
scenesActionList.Add(SceneManager.UnloadSceneAsync(sceneIndex));
}
public void Load(bool loadingScreen = false)
{
StartCoroutine(LoadingProgress());
}
public IEnumerator LoadingProgress()
{
Debug.Log(scenesActionList.Count);
yield return null;
}
}