Hello, I’m currently starting to expand my skills in the gui side of scripting, I’ve seen that foreach/for loops can be used to give each i in a list the same property or do something * the amount of things in the list,
but how do i use it properly? the script at the bottom of this thread currently loops forever, do i have to move it to its own function or perhaps add a bool? so it only loops when the bool is true? any help would be greatly appreciated, thanks!
the script
Delcaring
public Rect slotRect;
public Rect slotRectoffset;
public List<string> TestList= new List<string>();
void start
TestList.Add("0");
TestList.Add("1");
void OnGUI()
foreach(string i in TestList)
{
GUI.Button (new Rect (slotRect.x + slotRectoffset.x, slotRect.y + slotRectoffset.y, slotRect.width, slotRect.height), i);
slotRectoffset.x += 50;
}