Hello just thought of a way to refine my GUI system usauly i have a list of ints and a switch statement mapping each int to a method for an interface. However i thought it would be simpler to just have a list of the methods if possible and invoke them. I looked up on google how to make a list of methods and there isnt much besides using something like this (see code) and that doesn’t work. I think it might need to be a delegate but i don’t really understand how they work yet. Any help would be appreciated thanks.
//list of actions(methods)??
List<Action> CurrentMenus = new List<Action>();
//no idea what () => dose just put in my method
void Start() {
CurrentMenus.Add(new Action(() => {GWelcome();}));
}
void OnGUI() {
foreach (Action a in CurrentMenus) {
a.Invoke();
}
}