How do I create label fields upon GUI.Button/GUILayout.Button click in EditorWindow?

Hi,

I am creating a very simple object replacer tool using an Editor Window. Inside the Editor Window, I wish to create labels every time a button in there gets clicked. I have tried printing to the console, so the button click works. It just fails to create a label at all.

if (GUI.Button(new Rect(3, 25, position.width - 6, 20), "Click Test"))
{
        EditorGUILayout.BeginVertical();
        {
              EditorGUI.LabelField(new Rect(10, 10, 50, 50), "Test"); 
              this.Repaint();
         }
         EditorGUILayout.EndVertical();
}

Thank you,

Rajesh Iyer

private bool _createLabel = false;

void OnGUI()
{
     if (GUI.Button(new Rect(3, 25, position.width - 6, 20), "Click Test")) 
       _createLabel = true;

    if (_createLabel){

      EditorGUILayout.BeginVertical(); 
      EditorGUI.LabelField(new Rect(10, 10, 50, 50), "Test");  
      EditorGUILayout.EndVertical();

    }
}