can a function be stored in an array AND called using its index?

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.

5 Likes

THANKS!
it worked!