I’m on a team that’s making a short game that consists of two scenes: the start screen, and the game itself. The start screen has a Play button that when clicked, loads the scene that contains the game. When the game ends (on a win, loss, etc.) the main menu is loaded again. If you click Play a second time however, I get the following error:
“MissingReferenceException: The object of type ‘GameObject’ has been destroyed but you are still trying to access it.”
I don’t understand how this is possible. I thought that when you load a level, everything is restored to its initial state. Is that not the case? And if it is, why would it work the first time, but not the second time?
We never explicitly tell Unity to destroy the gameobject, so I’m assuming it’s getting destroyed (along with everything else) when we load the main menu scene, and then for some reason it isn’t getting recreated when we load the game scene the second time. The weird thing is though, when I pause the game and look at the scene, the gameobject in question is still there in the hierarchy. Does anyone know what could be causing this?