title: Change Window Layout with GUILayout.Button in Unity & C#
body: <p>I'm trying to make a menu in Unity using GUILayout buttons (and Begin/End Vertical/Horizontal, etc.) and I want it so that when I click a button, certain information displays below it. I'm trying to do it with this code:</p>
  
  <p>foreach (Agent agent in agents)//(Agent agent in EntityManager.FindAll())
          {</p>
  
  <pre><code>    //GUILayout.BeginHorizontal();
  
      if (GUILayout.Button(agent.shortName))
      {
              Debug.Log("clicked" + agent.shortName);
          GUILayout.BeginHorizontal();
          GUILayout.BeginVertical();
          GUILayout.Label("Health: "+agent.Health +"/"+agent.MaximumHealth);
          GUILayout.EndVertical();
          GUILayout.EndHorizontal();
  
          GUILayout.BeginHorizontal();
          GUILayout.BeginVertical();
          GUILayout.Label("Thoughts: nothing");
          GUILayout.EndVertical();
          GUILayout.EndHorizontal();
          /*if (agent.hasFlag)
          { //TODO: Add this function to agent
              GUILayout.BeginVertical();
              GUILayout.Label("Has the flag");        
              GUILayout.EndVertical();
          }*/
      }
  
          //GUILayout.EndHorizontal();
      }
      GUILayout.EndHorizontal();
      GUILayout.EndVertical();
  
  
      // Make the windows be draggable.
      GUI.DragWindow();
  </code></pre>
  
  <p>This successfully creates 3 buttons (since I have 3 agents in the agents list used in the foreach loop) and the buttons work (which is why the Debug.Log code was added). However, none of the things I added (such as the Labels) appear on clicking the button. What is the correct way to do what I'm trying to do?</p>