How to make game elements wait, for a sequence of events, to load?

I’m using the elements from the 2d-roguelike tutorial.

I’ve modified the code to load each tile on a click of the mouse. I’m trying to make the game wait until the level is fully loaded before the game really begins.

I tried deactivating the player and sound objects and then activating them after the level has loaded, but it turns out finding a non-active game object is tricky.

Then I tried leaving the Player Object active and then leaving the player script and layer spriterender deactivated at launch and activating them via script. This worked, but there is an error when the next level loads that says:

MissingReferenceException: The object
of type ‘Player’ has been destroyed
but you are still trying to access it.
Your script should either check if it
is null or you should not destroy the

I can’t help but feel like there is a better way to do this.

Any help is appreciated.

You could use OnLevelWasLoaded() before activating your objects or you could use an event system that fires an event when you want the objects to be loaded and the object’s event handlers then load them.