In my project I'm implementing an action class and was wondering if it was possible to pass a function as a parameter like this:
public class Action : MonoBehavior {
public int ID;
public string Name;
//Test variable to store a function here
}
Where later I would create a function, such as this one, and call it.
void TestFunction() {
print("Test");
}
public Action ExampleAction;
ExampleAction.Test = TestFunction();
And then finally I could simply call "Action.Test" to run TestFunction.
I've done some research on the topic and I believe it's somewhat related to delegation but how could I do it in this scenario?
And even more, is this sort of implementation reliable or the nicest way to do it? In my project I plan on having a lot of toggleable actions, that when clicked, will continuously do a large variety of different things.