Skip to main content
Unity3D

Unity3D Scripting API -2: MonoBehaviour

By January 22, 2021February 14th, 2021No Comments
Unity3D Scripting API
💚MonoBehaviour💚 is the base class from which every Unity script derives. Any Unity3D script that you create will extend the MonoBehaviour class.
https://www.youtube.com/watch?v=X5eSi-31jQg&feature=youtu.be

Ok what is a class? When you make a new Unity3D script, the class name will be the same as the file name. A class is like a container for your variables and functions. They’re organized together and perform a specific function in your game, for example character movement script will be a class by itself.

The MonoBehaviour class will execute events in a per-determined/certain order

For example:

Start(): This method is called right at the start of the game before Update() is called
⭐ Update(): Update method is called every frame
⭐ Awake(): Awake method is called when the script instance is being loaded
⭐ onDestroy(): Called when an object is destroyed⭐ OnCollisionEnter(): When 2 colliders hit/touch each other

Full list here: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html

To use any of these event methods, your script must extend from the MonoBehaviour class which contains all these events methods.

🍱Method: A method is a function that performs a specific task. So these methods are performing a specific function. For example whatever code is written inside the Start() will execute when the game starts.

Leave a Reply