I have a problem when I try to reset a scene. It doesn't seem to run, I have a script (of all scripts that have Awake and Start methods on that scene) that on the Awake method starts a coroutine, but when reseting the scene it doesn't even run it. I've read that it may be a problem of using the DontDestroyOnLoad method, but that doesn't seem to solve the problem since that script on the start takes a lot of references of objects that are only on the scene that I want to restart. I don't use any static variables on any script.
I made an unitary test trying to restart a scene with just one object and one script attached, on its Start method it also starts a coroutine but even in that test it doesn't even run the coroutine.
Here's the script of the unitary test:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class LoadingSceneController : MonoBehaviour
{
void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
//Scene scene;
// Use this for initialization
void Start()
{
//scene = SceneManager.GetActiveScene();
DontDestroyOnLoad(this.gameObject);
useStartCoroutine();
}
void useStartCoroutine()
{
StartCoroutine(loadScene());
}
IEnumerator loadScene()
{
yield return new WaitForSeconds(3);
SceneManager.LoadScene("gameplayScene 1");
//SceneManager.LoadSceneAsync("gameplayScene 1");
}
}