- Home /
Where to place main controller code?
Is there anything similar to the Document class in ActionScript? i.e. somewhere that I can place engine code that manages the game? or can I only run code that is attached to game objects?
Just put it in a game object called GameController, it doesn't really matter where you put it.
Answer by Mike 3 · Jul 16, 2010 at 10:22 PM
You have to have at least a single gameobject with a script on as an entry point - after that, it's up to you.
Is there anyway to control the order in which things load?
What do people normally use? the main camera?
There isn't a way no - generally you put code which is for internal setup into Awake, then use start for finding components and interacting with other scripts. Personally, I put my initial game code in a small prefab object, which i can add into any project easily
Answer by Lance Sun · Jul 17, 2010 at 02:45 AM
What we do is we have a scene called "Shell". This shell scene contains a single GameObject with our main MonoBehaviour class attached to it, and nothing else.
From there, we programmatically instantiate and update whatever we need.