i want to store some functions in an array and then call one of them using its index position in the array instead of its name. is that possible?
thanks!!
i want to store some functions in an array and then call one of them using its index position in the array instead of its name. is that possible?
thanks!!
Yes
private Action[] actions = new Action[3];
void Start() {
actions[0] = Foo;
actions[0]();
}
void Foo() {
Debug.Log("Foo got called");
}
See delegates.
THANKS!
it worked!