Hi,
i want to ask you about double overriding build-in methods in C#.
I have 3 classes “Base” “MiddleBase” “End”.
In Base:
public class Base : MonoBehaviour {
public virtual void Start () {
Debug.Log("Start Base");
}
public virtual void Update () {
Debug.Log("Update Base");
}
}
MiddleBase :
public class MiddleBase : Base{
public virtual void Start() {
base.Start();
Debug.Log("Start MiddleBase ");
}
public virtual void Update() {
base.Update();
Debug.Log("Update MiddleBase ");
}
}
End:
public class End: MiddleBase {
public override void Start()
{
base.Start();
Debug.Log("Start End");
}
public override void Update()
{
base.Update();
Debug.Log("Update End");
}
}
What i want to get is:
Start Base
Start MiddleBase
Start End
Update Base
Update MiddleBase
Update End
Update Base
Update MiddleBase
Update End
…
Well, as you probably know already, it doesn’t work. Only Base and MiddleBase are running, End doesn’t.
My question is, how to multiple overriding build-in methods like Start and Update?
In addition, i want to do the same with OnCollisionEnter2D but i guess i will have same problem.