In the editor UI and have dynamic lists of GUI elements, like having a GameObject array and using a for loop to iterate through them and say, display a vertical list of thier names using GUILayout.
void OnGUI(){
foreach(Thing thing in things){
GUILayout.Label(thing.name);
}
}
how can i get a list i can populate, resulting in an automatic layout of UI.
Will i have to manually instantiate and position/setup the text object in the scene?
If so, i suppose ill have to figure out positioning, of the anchor / rect, relative to screen size.
You can add a new UIComponent to the scene where you want the text boxes to reside if you then add a “vertical layout group” component to the object all elements you add will be stacks vertically. you will also need to add a “layout element” to each of the child elements (the text elements) and set the width and height on the layout element. this will stack all the child elements so they are positioned according to the criteria on the layout elements.
For a bonus you can add another parent container and attach a “scroll rect” component to it and make the first component that has the “vertical layout group” on it as the “scroll rects” container and you can scroll you list.