- Home /
Question by
tomazsaraiva · Sep 08, 2011 at 03:52 PM ·
guiarraylabel
Creating a GUI Label List from Array
Hey,
I'm trying to create a GUI List from an Array of Strings. The lenght of the array is not fixed so what I need to do is to add/remove labels from the Array lenght.
How can I do this?
Thanks for any help
Comment
Best Answer
Answer by Sydan · Sep 08, 2011 at 03:56 PM
Something like:
for(i=0;i<array.length;i++)
{
GUI.label(Rect(x,y+(i*h),w,h),array[i]);
}
Where, x, y, w, h are the dimensions of your label.
Took me awhile to work it out when I first had to do it :P There was mathematics involved... so I found it tricky, but I now use this method nearly every time. If someone knows a better one though, I'm open to that.
Your answer
![](https://koobas.hobune.stream/wayback/20220612205058im_/https://answers.unity.com/themes/thub/images/avi.jpg)