You can use base
to call the base class' implementation of Start()
. You also have to override
the virtual
method in the child class:
protected override void Start () { base.Start(); BlahBlahBlah(); Stuff();}
You can also use template method pattern to define the skeleton of the method in the base class and provide implementation of some parts in derived classes.
public void Start() { MyRigidBody = gameObject.GetComponent<Rigidbody>(); if(Controls.Length < 4) throw new System.Exception("Controls not assigned correctly"); DoSomethingElse();}protected virtual void DoSomethingElse(){ //can be empty in base class, derived classes provide the implementation}
The Start
method is not virtual. If you want to modify the behavior of Start
method in derived classes, you override DoSomethingElse()
.