C
C#3y 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
YonatanOP3y ago
I tried doing it myself on visual studio Community but I get an error: no suitable method found to override.
Thinker
Thinker3y ago
No, the signature of an override has to be the exact same as the method it's overriding. You cannot add parameters.
Yonatan
YonatanOP3y ago
Alright, Thanks, Is there any way to workaround this? or should I just make a new function
Thinker
Thinker3y ago
You should probably just make a new function
Yonatan
YonatanOP3y ago
Cool, Thanks.
Want results from more Discord servers?
Add your server