We know that event functions such as Start () Update () are called sequentially in the unity main thread. The order of calls can be found in the manual.
Some changes will also occur with this inheritance mechanism.
Test One:
Public class mytest2:monobehaviour{ void Start () { //Eventdelegate.add ( Tween.onfinished, Test, true); Debug.Log (""); } void Update () { Debug.Log ("");} }
Public class mytest3:mytest2{ // Use this for initialization void Start () { C10/>debug.log (""); } void Update () { Debug.Log ("");} }
Run:
Test Two:
So what happens if the MyTest3 start Update is commented out.
Public classmytest2:monobehaviour{voidStart () {//Eventdelegate.add (tween.onfinished, Test, true);Debug.Log ("MyTest2 Start"); } voidUpdate () {Debug.Log ("MyTest2 Update"); }} Public classmytest3:mytest2{//Use this for initialization//void Start ()//{ //Debug.Log ("MyTest3 Start"); //} //void Update ()//{ //Debug.Log ("MyTest3 Update"); //}}
Run:
Familiar with C # knows that no modifiers are private by default. It seems that unity has a special handle on this kind of function.
Test Three:
So let's look at other inheritance features.
Public classmytest2:monobehaviour{//virtual or abstract members cannot be private Public Virtual voidStart () {//Eventdelegate.add (tween.onfinished, Test, true);Debug.Log ("MyTest2 Start"); } voidUpdate () {Debug.Log ("MyTest2 Update"); }} Public classmytest3:mytest2{//Use this for initialization Public Override voidStart () {Debug.Log ("MyTest3 Start"); } voidUpdate () {Debug.Log ("MyTest3 Update"); }}
The result appears to be the same as the test one. In other words, you will find the final instantiation of there is no, and then find the parent class has no.
Unity3d-The inheritance mechanism of the Functions of the beginner's story Event