So what I’m trying to do is create a variable number of GUI.Box with some simple data in them and have them appear within a window. Currently the way I’m accomplishing this is by creating an ArrayList of an object with the code to make the GUI.Box in the OnGUI function of the created class. The problem with this is that I can’t hide those boxes within the window or prevent the boxes from extending down beyond the bounds of the window.
I’ve also tried a foreach loop, but the problem there is that it only shows one box at a time when called from the window.
If anyone knows how to accomplish enumerating Boxes within a window, I would greatly appreciate the help. I apologize if my description of what I’m trying to achieve is confusing, I’m a little stuck on how to describe it as well.
Old Code:
public class FPSMenuScript : MonoBehaviour {
private string name;
public ArrayList actors;
private Rect sideBarWindow;
void Start () {
actors = new ArrayList();
i = 0;
sideBarWindow = new Rect((Screen.width - 160f),10f,150f, Screen.height - 170f);
}
void OnGUI()
{
GUI.Window (0,sideBarWindow,ActorWindow,"Actor Window");
}
void ActorWindow(int windowID) {
if(GUI.Button (new Rect(5f,5f,100f,30f),"Add Actor")){
actors.Add();
}
}
}
public class ActorGUI : MonoBehaviour {
public Rect actorRect;
public int actorNumber;
public string actorName;
void Start () {
actorRect = new Rect(Screen.width - 150f, 50f + 55f*actorNumber, 140f, 50f);
}
void OnGUI () {
GUI.depth = 0;
GUI.Box (actorRect, actorName);
}
}