Not loading an object if it have be retained from a previous scene.


I'm retaining a gameObject called "OverControl" (It's used to keep track of all the games overall functions), using dontdestroyonload.

The problem, is when I return to the menu, when it's first instantiated... It load the one in the menu too. So I'm then stuck to having two of them.

So my guess is that I'd have a pre-loader screen that will set and instantiate everything that is needed, so that there's a screen that the player doesn't return to.

Or, create an object that instantiate the "OverControl" if it doesn't exist.

So I ask, what would be the best solution? Considering there will be a "Save" that will be deeply intertwined with the "OverControl" later on.

I think you've basically enumerated the two solutions that I would consider for something like this, those being:

  1. Place the object in a scene that's never returned to (such as a splash screen or intro of some sort).

  2. Write code that creates the object dynamically, and that ensures only one such object is created.