Window System
Easily manage in game windows, panels and dialogs.

Introduction

Available in UX Complete
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.
Check out the following articles for more details on specific componenets
Window
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.
Works great with the Cursor Tools Button Cursor State

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 behavior.

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

1
public static Window focused;
Copied!
You can get the Window object that is currently focused from the static focused attribute.
1
var focusedWindow = Window.focused;
Copied!

Focus a Window

This assumes the window you wish to give focus to is named targetWindow
This set the target window as the Window.focused and moves the window to be on top of non-Always On Top windows.
1
targetWindow.Focus();
Copied!

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
1
//Get the position
2
position = targetWindow.Position;
3
4
//Set the position
5
targeWindow.Position = position;
Copied!
This respects the "anchor" you set in Unity's Rect Transform. For example if you want the window to move relative to its upper left corner then you should set the anchor position of its Rect Transform to the upper left corner.

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
1
//Get the width
2
width = targetWindow.Width;
3
4
//Set the width
5
targetWindow.Width = width;
Copied!
This respects the "anchor" you set in Unity's Rect Transform. For example if you want the window to move relative to its upper left corner then you should set the anchor position of its Rect Transform to the upper left corner.

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
1
//Get the height
2
height = targetWindow.Height;
3
4
//Set the height
5
targetWindow.Height = height;
Copied!
This respects the "anchor" you set in Unity's Rect Transform. For example if you want the window to move relative to its upper left corner then you should set the anchor position of its Rect Transform to the upper left corner.

Transform the window

This will set the windows position and size at the same time.
1
targetWindow.SetTransform(size, position);
Copied!

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.
1
targetWindow.DockTo(targetRect);
Copied!