MonoBehaviour

Can anyone give me an example how Monobehaviour works.
Why only 2 methods are created like Start() and Update() method I believe there are more.
Why Start() is run only once and Update() per each frame.How can be created an example with new independent classes without MonoBehaviour inheritance.
Is there any special key that makes some method shown and some not in the new class and if there is a code that makes Update () repeat per frame and Start() only once.

Unity uses reflection to check if there are methodes like Update, Start, Awake, FixedUpdate…(complete list in the docs) on a MonoBehavior instance and if it finds them calls them. If you don’t want that calls remove the functions. if you want an independent class, just remove MonoBehaivior as parent. MonoBehaiviors are tied to GameObjects, that’s why you can see and change some many property’s of the GameObject the MonoBehaivior is attached to. But that also means only child’s of MonoBehaivior get to be attached in the inspector to a GameObject. I know that’s a ruff explanation here, but that topic was explained many times on here and on the forum. I know your to hip to google, but there are other search engines as well :wink:

The gubbings of the new source file when you click Create are just the most commonly needed things. You are free to add more or remove them altogether. Check the link above for the MonoBehaviours which are literally just an exposure of the Loops and Messages of the game engine in order for you to add your pieces to. MonoBehaviours help us to not reinvent the wheel. Otherwise we’d be writing our games from scratch :wink:

More information here ← READ THIS

So as Oribow says, you are free to write a class which does not derive from MonoBehaviour. Such a class does not need to be added to a GameObject whereas a MonoBehaviour derived class MUST be attached to a GameObject as a component.