Hello,
I have been experimenting with Unity and have built one scene but now would like to create another. In my first scene I created a script called game controller that has a lot of the logic for the game, I have figure out how to add a new scene and its going to use a lot of the logic, but if you restart I need to go back to first scene and I want the score to follow the user to the second scene. What are the best practices for this, do you have separate game controllers for each scene? Any links to good best practice documentation would be great. I am using Unity 5.5.
Thanks.
For GameObjects that are so important that you need them throughout the game, you can make them a singleton. If you’re not familiar with the pattern, look it up in the internet, there’s plenty of information about it.
THIS HERE is an implementation and explanation of use for one version of it specifically designed for Unity. Since Unity forbids the use of MonoBehaviour constructors, the way it’s implemented is a lot more complicated than a standard C# singelton.
With it, the manager will stay once accessed. If it happens in a scene before the one you’ve set it up, it get’s created on the fly without any references you’ve setup in the inspector, so make sure that doesn’t happen.