I need help...

I’m not all that great at doing adaptive GUI Design…

I’m looking to create a “list” of sorts, with these parameters…

I have an array that contains the list data. I would like to iterate throgh the array (using “for (i = 0; i < array.Length; i++)”), and draw a text field containing each object in the array.

I would like the text field to adjust it’s size, so that it’s entire content is displayed.

These text fields will all be displayed in a scrollview.

Finally, I would like to have a button appear next to each text field.

I’m totally baffled by this, and any help you can give is greatly appreciated!

This is off-the-cuff so it may not compile, but I’m pretty sure it is close to what you want. (it is in C#)

public class YourScript : MonoBehaviour
{
  public string[] yourArray = new string[0];
  public Rect box = new Rect(10,10,200,200);
  Vector2 scroller;
  
  void OnGUI()
  {
    GUILayout.BeginArea( box );
    scroller = GUILayout.BeginScrollView( scroller );
    GUILayout.BeginVertical();
    for( int i=0; i<yourArray.Length; i++ )
    {
      GUILayout.BeginHorizontal();
      yourArray[i] = GUILayout.TextField( yourArray[i] );
      if( GUILayout.Button("Button for " + yourArray[i] )
      {
        Debug.Log( "You clicked button for " + yourArray[i] );
      }
      GUILayout.EndHorizontal();
    }
    GUILayout.EndVertical();
    GUILayout.EndScrollView();
    GUILayout.EndArea();
  }
}