Scripting in Unity
- Linking MonoDevelop to Unity
- 1. Run Unity
- 2. Under Edit > preferences, under External script editor browse and select mono develop
- 3. If asked to restart unity do so
Your unity application should be linked to mono develop now
Script Execution Order in Unity
Unity makes no guarantees about the order scripts will be executed from pass of the main game loop to the next. This is a fact of life of working with Unity, but you do have some level of control over when things can execute in relation to each other through the built in functions of MonoBehaviors. MonoBehavior is the base class that any script that you want to be a component of a GameObject should inherit from. More information
Here are some of the functions of MonoBehaviors that you can define.
- Awake() - is called first whenever an object is instantiated.
- Start() - is called after Awake(), this is where you will usually set up variables that are dependent on other components
- Update() - is called every frame as often as Unity can and is dependent on your game's framerate. The faster it is running, the more often it will be called, and vice versa. Therefore, anything that happens in update that is time dependent should use Time.deltaTime to make it framerate independent.
- FixedUpdate() - FixedUpdate is called every fixed framerate frame. Frequency of FixedUpdate calls can be configured under Edit->Project Settings->Time
- OnGUI() - is a function that draws all the GUI elements. For more information please look at UnityGUI
- For more information