Ever wonder how the magic
events of unity Behavior works:
void Awake()
{
}
void Start()
{
}
void Update()
{
}
// Or other unity magic events
like OnEnable, OnDisable, Late Update, Fixed Update, etc.,
The simple answer comes into
mind that maybe unity use reflections to find Mono Behaviour methods in order
to call it every time or maybe they use override to those methods but
apparently, this is not happening. So how it calls its event especially the Update
event that calls on every frame.
The way unity3d Messaging system works its:
1. Unity
scripting runtime Mono or IL2CPP access MonoBehaviour derived
(type) script.
2. Look
for magic events and cache it.
3. Like
if a MonoBehaviour derived
script has an update event then the script will be added into a list (list of
scripts) that will be updated on every frame.
4. Now
during gameplay, unity iterates over the list and fire the Unity events. This is
the reason that if you make your event public or private they don’t get
effected.





