Hey everybody!
I'm very curious about how to do the same as Unity does with Update and Start methods. Like having a script which handles the function calling and call the method for each script that has this method implemented in the class.
The only way I know how to do this is using events and delegates, but this way I need to subscribe the method to the event(or delegate, just forgot), and I want something more 'automatic', like:
public class MethodHandler: MonoBehaviour {
void CallSometime();
void Update () {
if(blabla == blabla1) {
CallSometime();
}
}
}
public class MethodImplementation: MonoBehaviour {
void CallSometime () {
print("I've been called!");
}
}
Note that 'MethodHandler' doesn't know about the existance of 'MethodImplementation', howerer, CallSometime() is called in 'MethodImplementation' when it's called in 'MethodHandler', just like the Update() and Start() methods. Is this possible?
Thanks from now!
↧