Resizable and draggable "Window" for gui.

attach the WindowBase script to a panel or ui element or something. Also make sure theres just a gameobject in your scene with recttransform with tag of “Border”. the script will build sections of border around the ui element, which you can drag with your mouse to resize the element and stretch it around. Play with the inspector values in the WindowBase to change settings.

Let me know what you guys think :smile:

dropbox to zipped project: Dropbox - Error - Simplify your life
i also attached the two scripts to this thread.

NOTE: theres a tiny glitch if you set the style enums to relative, and if you drag to fast the element creeps a few pixels. dont know how to fix it yet. i just wrote this now.

next i want to make it able to be locked to within screen limits (cant move the window to where a part of the panel is off-screen). ill save that for another day though

1861806–119459–WindowBase.cs (23.2 KB)
1861806–119460–WindowBorder.cs (1.1 KB)

Applying dragging results directly based on PointerEventData.delta is not recommended. It won’t work well for world space UI, or UI elements with any kind of rotation or use of perspective.

The UI example project ( Unity Asset Store - The Best Assets for Game Making ) includes an example scene with a draggable and resizable window. It’s somewhat simpler than the one posted here - resizing only works on the lower right corner - but it is a solid foundation that works for both screen and world space Canvases and for any arbitrary rotation or use of perspective. It can then be built upon to include more full functionality.

1 Like