Hi everyone, Is there a way to create an if statement for each element within a list? I want each of my buttons do something different but I 'm not sure how to set that up.
public List<ButtonInfo> ListOfButtons;
public class Buttoninfo
{
public int ButtonFunction = 0;
}
Void OnGUI(){
for (int i = 0; i < ListOfButtons.Count; i++)
if (GUILayout.Button("Button", GUILayout.Width(125), GUILayout.Height(25)))
{
Buttoninfo*.Value++;*
}
//This is all I could come up with. It’s incredibly inefficient and I would Like to change it
-
if(ListOfButtons[0].ButtonFunction == 1){}*
-
if(ListOfButtons[1].ButtonFunction == 1){}*
-
if(ListOfButtons[2].ButtonFunction == 1){}*
-
if(ListOfButtons[3].ButtonFunction == 1){}*
-
if(ListOfButtons[4].ButtonFunction == 1){}*
-
if(ListOfButtons[5].ButtonFunction == 1){}*
}