What I want to do is use an array of delegates to create multiple listeners on buttons.
something like this:
List myList<Delegates> = new List<Delegates>();
myList.add(Use);
myList.add(Destroy);
myList.add(Etc);
foreach(Delegate delegate in myList
{
GameObject obj = (GameObject)Instantiate(MyButton, myTransform);
obj.GetComponent<Button>().onClick.AddListener(delegate);
}
Is this possible? The end result is a UI with buttons for each method stored this way on an object. So different objects will have different methods stored and generate a different set of buttons for the UI. If it isn’t possible, what would be the best way to achieve this?