C
C#2y ago
Yonatan

Override Function and add variables?

is it possible to have a function in the base class:
public virtual void StartSpawnAnimation()
{
Debug.Log("Test");
}
public virtual void StartSpawnAnimation()
{
Debug.Log("Test");
}
And than Override it in a derived class and add a variable:
public override void StartSpawnAnimation(bool Something)
{
Debug.Log(Something);
}
public override void StartSpawnAnimation(bool Something)
{
Debug.Log(Something);
}
?
5 Replies
Yonatan
Yonatan2y ago
I tried doing it myself on visual studio Community but I get an error: no suitable method found to override.
Thinker
Thinker2y ago
No, the signature of an override has to be the exact same as the method it's overriding. You cannot add parameters.
Yonatan
Yonatan2y ago
Alright, Thanks, Is there any way to workaround this? or should I just make a new function
Thinker
Thinker2y ago
You should probably just make a new function
Yonatan
Yonatan2y ago
Cool, Thanks.