edit: I noticed how my simplified example doesn’t use guilayout (oops) but it still has the issue! The button of the draggable window doesn’t fire any event.
Hi there,
I realized that if one uses GUI.DragWindow(…) inside a window function called by GUILayout.Window the buttons stop working as expected, the button visually reacts to the press but doesn’t return “true” (thus not calling anything it’s supposed to).
It took me some time to track this bug down. In fact, I can make the button work by pressing both mouse buttons at the same time. How weird is that?
So, is there a way to make guilayout.window draggable? the docs says it’s possible but doesn’t say how, and the forum search shows people making it draggable exactly the same way as above. Didn’t the try putting any buttons inside the function? or maybe I’m doing something wrong? Here’s a simplified code that “works” (“works” as in “doesn’t work”)
var windowRect1 : Rect = Rect (20, 20, 120, 50);
var windowRect2 : Rect = Rect (50, 50, 120, 50);
function OnGUI () {
// Register the windows
windowRect1 = GUI.Window (0, windowRect1, DoMyWindow1, "My Window 1");
windowRect2 = GUI.Window (1, windowRect2, DoMyWindow2, "My Window 2");
}
function DoMyWindow1 (windowID : int) {
GUI.DragWindow (Rect (0,0,10000,10000));
if (GUI.Button (Rect (10,20,100,20), "button"))
print ("clicked on button of window 1");
}
function DoMyWindow2 (windowID : int) {
if (GUI.Button (Rect (10,20,100,20), "button"))
print ("clicked on button of window 2");
}