could I control the GUI.DragWindow range?

Hi all!

I’ve a whole screen menue, but with a menu left sided. The menubutton opens a new window in the wholescreen window.

The new window is draggable, but for sure it would be nice to force it not to overlay with the menue or topscreen discription.

Could I define a zone or something like that?

Using the DragWindow example from the scripting reference. Just modify the coordinates in the GUI update after they are set.

There’s probably a nicer way constrain the position. Haven’t really done anything with gui windows :slight_smile:

using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour {
    public Rect windowRect = new Rect(20, 20, 120, 50);

    void OnGUI()
    {
        windowRect = GUI.Window(0, windowRect, DoMyWindow, "My Window");
        // constrain the window rect x / y
        windowRect.x = Mathf.Clamp(windowRect.x, 0, 300);
        windowRect.y = Mathf.Clamp(windowRect.y, 0, 500);
    }

    void DoMyWindow(int windowID)
    {
        GUI.DragWindow(new Rect(0, 0, 10000, 20));
    }
}

At last an answer… Ty bro… I’ll try out tomorrow! :wink: