The life cycle of a script instance
In the previous section, we introduced basic concepts of scripting in Unity. Now, we will explain another important topic regarding scripting in Unity: the life cycle of a script instance.
We already know that the Unity C# API does not include the internal logic of the engine and the event functions on the script are triggered by the engine's C/C++ code. Therefore, in order to use the Unity engine correctly, it is very important to understand the order of execution for event functions and the life cycle of a C# script in Unity.
We can divide the Unity event functions into the following categories depending on their purpose :
- Initialization
- Update
- Rendering
Let's discuss them next.
Initialization
If you are familiar with developing .NET applications, you may be surprised by script initialization in Unity because Unity scripts do not use constructors for initialization. Instead, Unity provides some engine...