Hello. I have a really burning question. Whenever i reload a scene or reopen a scene after exiting a another scene I keep getting null reference exceptions on my variables. Basically i am making a racing game so there will be a lot of scene switching. currently I have 5 scenes: 1 splash scene, 1 garage scene and 3 race scenes. The game is programmed to go to the garage, the user picks a race scene, then when the race is is won(or lost or quit) the user presses a button to go back to the garage scene. Whenever i reload the race scene or go back to the garage scene i get the null reference exception.
I don’t have any singletons, toolboxes, static classes or static variables. None of my scripts use
DontDestroyOnLoad(). Most if not all of my scripts in the scene use
Start() to set the variables and reference each other at the start of the scene and then they do their business. I’ve when through about 12 forums and Unity Answers pages and I don’t understand anything even though most of them are marked as answered. Some recommend manually setting variables to null and some say to unsubscribe from event handlers, but I don’t think I subscribed to any in the first place. I even tried using
SceneManager.UnloadScene before using
SceneManager.LoadScene. Can someone please help me.