I only have a small experience in Unity3D, but I noticed that classes that derive from MonoBehaviour
may contain functions with predefined signatures that will be called in a special way. For instance, if I write:
void Update()
{
//some code
}
this method will be called every frame.
I imagine that inside Unity there is some sort of an endless loop that calls the Update
method every frame for each object on the scene. But how does it know that the object actually provides the Update
method implementation? It would have been clear if Update
was an override for a method in the MonoBehaviour
class, but judging by the syntax (and the fact that you can implement such methods with any access modifier) it's not. Is there some reflection magic happening there?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…