- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Palai · Mar 11, 2013 at 12:19 PM ·
multipleinheritancestart
Inheritance + void Start()
Is it possible to call Start multiple times in an inherited class? For example:
public class test1 : MonoBehavior
{
void Start()
{
Do.Something();
}
}
public class test2 : test1
{
void Start()
{
Do.Something();
}
}
Comment
Best Answer
Answer by Bunny83 · Mar 11, 2013 at 01:08 PM
Of course, but you have to do it like usual. That means the function needs to be virtual and you have to override it in the derived class:
public class test1 : MonoBehavior
{
public virtual void Start()
{
Do.Something();
}
}
public class test2 : test1
{
public override void Start()
{
base.Start();
Do.Something();
}
}
You really should use classnames that start with a capital character. Only variable names and keywords start with a lower-case character.
Really? I swear I tried that and had to resort to the method in my answer. Oh well, good to know. And you beat me to it T_T
Your answer
![](https://koobas.hobune.stream/wayback/20220613094212im_/https://answers.unity.com/themes/thub/images/avi.jpg)