Window System
Easily manage in game windows, panels and dialogs.
Like what your seeing?
Support us as a GitHub Sponsor and get instant access to all our assets, exclusive tools and assets, escalated support and issue tracking and our gratitude. These articles are made possible by our GitHub Sponsors ... become a sponsor today!
Introduction
The Window system makes it easy to define drag-able, re-sizable and dock-able windows in your game. The simple system can be attached to any Rect Transform and supports all canvas modes and all anchoring types. Window groups can be defined easily by simply parenting them in there own Rect Transforms where windows focus (move to top) and clamp (remain in frame) according to there parent.

With this system, you have complete control of your window's features including resize and move handles. You can choose to add a move handle, allowing the window to be dragged around the parent, rather or not it clamps to the parent and rather or not it remains always on top of other windows.

Searchable Windows
The API.Windows interface makes it easy to search for and manage all available windows and identify the currently focused window. Windows use the Selectable Tag system meaning you can tag your windows with multiple tags and search for windows with matching tags.
For more information please review the API.Windows interface article.
Configuration
Move Handles

Intended to be added to a child object of your window the RecTransform this is added to will be the clickable area that when clicked allows the user to drag the window.
Border Handles

Similar to the Move Handle, the Border Handle is intended to be added to a child object of your window, the RectTransform of which will be the clickable area that when click allows the user to drag to resize the window. Border Handles need to be told what part of the border they are on as this effects the drag to resize behaviour.
Handle Types
Top Drag increases the height of the window from its top edge
Bottom Drag increases the height of the window from its bottom edge
Left Drag increases the width of the window from its left edge
Right Drag increases the window of the window from its right edge
Upper Left Drag increases the height and width of the window from its upper left corner
Upper Right Drag increases the height and width of the window from its upper right corner
Lower Left Drag increases the height and width of the window from its lower left corner
Lower Right Drag increases the height and width of the window from its lower right corner
Examples
Get the focused window
public static Window focused;
You can get the Window object that is currently focused from the static focused attribute.
var focusedWindow = Window.focused;
Focus a Window
This assumes the window you wish to give focus to is named targetWindow
targetWindow.Focus();
Set or Get Position
This example assumes the window to be moved is named targetWindow
and that you wish to move it to a location defined as position
//Get the position
position = targetWindow.Position;
//Set the position
targeWindow.Position = position;
Set or Get Width
This example assumes the window to be sized is named targetWindow
and that you wish to set its size to a value defined as width
//Get the width
width = targetWindow.Width;
//Set the width
targetWindow.Width = width;
Set or Get Height
This example assumes the window to be sized is named targetWindow
and that you wish to set its size to a value defined as height
//Get the height
height = targetWindow.Height;
//Set the height
targetWindow.Height = height;
Transform the window
This will set the windows position and size at the same time.
targetWindow.SetTransform(size, position);
Dock Window
This will snap the window to the position and size of the input RectTransform.
Scale is not accounted for in this operation. Its advised that you dock to transforms that in the same canvas or otherwise are at the same global scale as the window.
targetWindow.DockTo(targetRect);
Last updated