Let’s say I have
public virtual void Activate(){
// Do stuff here
if (true){
return child.Activate();
}
}
public override void Activate(){
base.Activate();
}
Let’s say I have
public virtual void Activate(){
// Do stuff here
if (true){
return child.Activate();
}
}
public override void Activate(){
base.Activate();
}
bump
what?
You’re going to have to rephrase your question. I have no idea what you’re asking for.
Also, use code tags!
OK you know how you can use “return;” to exit the method and stop it from executing the rest of the code?
Well I want to stop the exution of the method from the parent method. Is this possible? I know I could easily do it by using a boolean in the child method but I don’t want to.
Not possible?
So you want to be able to say something like ‘super return’ in the parent class so that all operation of the call to the method stops?
public class BaseClass
{
public virtual void Foo(bool condition)
{
Debug.Log("Doing some Foo work.");
if(condition)
{
Debug.Log("Cancelling all foo work!");
super return;
}
Debug.Log("Finishing Foo work in base.");
}
}
public class ChildClass : BaseClass
{
public override int Foo(bool condition)
{
Debug.Log("Overriding some Foo work BEFORE calling base.");
base.Foo(condition);
//this only will occur if 'condition' was false
Debug.Log("Overriding some Foo work AFTER calling base.");
}
}
Yeah, does NOT exist.
You’d have to implement this your own way… something like a referenced bool or something.
Edit - rereading this and I think I was misunderstanding the question. Yea Im not sure what you are asking for exists.
Thanks. Exactly what I was talking about.