Lets say I have a scene called **MainMenuScene** in which I have a `GameObject`, say, **Datasource_GO**.
On this I've assigned a script, say, **Datasource_CS.cs** whose contents can be simply:
void Awake() {
DontDestroyOnLoad(gameObject);
Debug.Log("Datasource_CS--Awake");
}
void Start () {
Debug.Log("Datasource_CS--Start");
}
From **MainMenuScene** I can go to, say, **GameScene** and then back to **MainMenuScene**.
The problem here is that with **DontDestroyOnLoad** I expected **Datasource_GO** to run the **Awake** method just once but everytime I load **MainMenuScene**, it executes **Awake**.
I believe it's the intended behavior so for now, I have put **Datasource_GO** in a dummy scene called **_DummyScene** that loads **MainMenuScene** with no route back to **_DummyScene** just to prevent **Datasource_GO** from executing multiple times.
I would like to know how you guys have/would handle this scenario or have any insight/alternatives to this.
↧