Custom Editor Window Nodes Unresponsive Button

I’m writing a custom editor window for dialogue trees. That has a series of nodes to represent lines of dialogue.

I want to have a button inside these Node Windows that calls a function. The button is, however, unresponsive and I can’t figure out why.

Here’s the code from OnGUI in the EditorWindow class that draws all of the nodes (they’re in a scroll area):

        GUILayout.BeginVertical();
        {
            scrollPos = GUI.BeginScrollView(new Rect(0f, scrollViewYStartPos, position.width, position.height-110f), scrollPos, new Rect(0, 0, 10000, 10000));
            {
                BeginWindows();
                for (int i = 0; i < dialogues.Count; i++)
                    dialogues<em>.windowRect = GUILayout.Window(i, dialogues_.windowRect, DrawNodeWindow, dialogues*.windowTitle);*_</em>

EndWindows();
}
GUI.EndScrollView();
}
GUILayout.EndVertical();
The node windows are created within the BeginWindows and EndWindows. The function to create them is:
private static void DrawNodeWindow(int id)
{
dialogues[id].DrawWindow();
}
And the code in the actual node that defines its display is:
public virtual void DrawWindow()
{
if (GUI.Button(new Rect(windowRect.width - 44f, 1f, 36f, 14f), “Size”))
{
ChangeWindowHeight();
}
}
^That’s the button that isn’t responding though. It just seems to get stuck when I press it.
Any help would be appreciated!
Thanks,
Matt

Well, first of all you’re mixing GUILayout and GUI stuff inproperly. Things inside a GUILayout group should all be “layouted” automatically. So using GUI functions inside a GUILayout group makes no sense.

GUI windows can be a bit tricky. In most cases it’s better to use GUI.Window instead of GUILayout.Window. The only difference is that the content of the window can cause the window rect to resize automatically (growth only). Since your window content isn’t layouted content you should use GUI.Window

Also your “BeginVertical” makes no sense since there’s no layouted content in between BeginVertical and EndVertical. It seems you want to use the normal (manual) GUI system, so you should replace GUILayout.Window with GUI.Window.

This works for me without any problems:

scrollPos = GUI.BeginScrollView(new Rect(0f, scrollViewYStartPos, position.width, position.height-110f), scrollPos, new Rect(0, 0, 10000, 10000));
{
    BeginWindows();
    for (int i = 0; i < dialogues.Count; i++)
        dialogues<em>.windowRect = GUI.Window(i, dialogues_.windowRect, DrawNodeWindow, dialogues*.windowTitle);*_</em>

EndWindows();
}
GUI.EndScrollView();
If it doesn’t work for you it might depend on what you do inside “ChangeWindowHeight();”
If you have trouble understanding how the IMGUI works, have a look at my [GUI crash course over here][1]. Maybe if i find the time i could add a few lines about GUI windows as well ^^.
_*[1]: http://answers.unity3d.com/answers/360910/view.html*_