Im not new to programming but I am new to Unity. So here is my question. How do you set a main game loop and global variables? I know I could set a dummy object but does that get cleared when you load a new scene? Thanks in advance.
http://forum.unity3d.com/viewtopic.php?t=35877 You can have as many "game loop"s as you want, not just one.
yeah but that is not good practice. I do not want to have keep repeating functions. Attaching countless scripts to every object. my main question is how I am suppose to keep my data and functions from one scene to the next? Like number of lives and score from level to level. AKA my global variables. There has to be a way to set them at the start of the game and keep them through out.
It is in Unity, where there isn't really any such thing as a "main loop". You should do some of the tutorials (like the third-person platformer) so you can get a sense of how things work. --Eric
So basically if I load a new scene I need to pass all the variables I want to keep from the scene I am in to the new scene? that seems excessive.. but I guess it would work if that is how it must be.
No, you can create the object once and then mark it with DontDestroyOnLoad. Or, you can use a singleton pattern.