What is MonoBehaviour in Unity?
Scripting for Unity
Unity previously Supported Boo, JavaScript, and C#, But it removed Boo with Unity 5 and JavaScript which is called UnityScript which is removed in August 2017, with Unity 2017.1. And Now Only C# left. It is the primary programming language for Unity.
Create a C# script in unity.:-
Its very simple to create and handle a script in Unity. Just Right Click anywhere in Project Window, Hover on create and Click on C# Script.
Script Management
The First Major thing is just after create the C# script Named it as you want in your Project. Because the Script name will be the Base Class of your Script. If you want to rename it, you must rename the Base class name Inside the Script.
Managing is also too easy here, just drag the script file in Unity and drop on any folder in Project Windows to move in it.
MonoBehaviour in Unity
The first word you saw in the C# Script just after the Name of your Base class. Actually it is your Base class from which every Unity Script Derives. It contains all the preDefined variables, public functions, static functions, Messages, and all Inherited members.
It Works with its Life Cycles for Unity as Follows:-
- Editor Mode
- Reset
- StartUp
- Awake()
- OnEnable()
- Start()
- Updates
- FixedUpdate()
- YieldWaitForFixedUpdate()
- Update()
- Yield null and YieldWaitForSeconds()
- LateUpdate()
- Rendering
- OnWillRenderObject()
- GUI
- OnGUI()
- YieldWaitForEndFrame
- TearDown
- OnDisable()
- OnDestroy