Window Framework for Unity UI Toolkit
Window Options
The Window Framework for Unity UI Toolkit is designed to provide a flexible and easy-to-use framework for creating runtime windows in your Unity projects. The framework allows you to create windows with various options and settings that can be customized to fit your needs and is compatible with UXML Documents created in Unity UI Builder.
Window Frames have various attribute settings that aid in the creation of the perfect window to suit the situation.
Since the Window Framework uses UI Toolkit Visual Elements all standard properties are available to the Window Frame, some have been added to the Window Frame class as UXML Attributes to make them easier to access and add additional needed functionality during use.
Elements such as the assigned USS style sheet for example use the Window Controllers Theme manager to assign the active theme USS style sheet to the window frame at runtime.
-
WindowId (
string - get, private set
)
Used to identify the window for memory purposes. -
ParentObjectId (
string - get, set
)
used to associate a window to a container or object allowing for size and location memory of the window based on an in-game world object such as inventory windows for many different parent containers. -
WindowFramePosition (
WindowFramePosition eNum – get, set
)
used to place the window on the screen. (Initial value only, window can be moved unless locked) -
WindowMemoryEnabled (
bool – get, set
)
Enables/Disable window location and sizing memory -
Title (
string – get, set
)
Title text displayed in header -
DefaultWidth (
float – get, set
) default = 300
Default starting width of window. MinWidth will also force starting size -
DefaultHeight (
float – get, set
) default = 300
Default starting height of window. MinHeight will also force starting size -
MinWidth (
float – get, set
) default = 150
MinWidth will also force starting size but can not be made smaller once created -
MinHeight (
float – get, set
) default = 150
MinHeight will also force starting size but can not be made smaller once created -
FullScreen (
bool – get, set
)
Forces window full screen -
ShowHeader (
bool – get, set
)
Show / Hide the header element of the window frame -
ShowFooter (
bool – get, set
)
Show / Hide the footer element of the window frame -
AllowClose (
bool – get, set
)
Allow / Deny the ability to Close the window, overridden when Locked= true -
AllowLock (
bool – get, set
)
Allow / Deny the ability to Lock the window in place and size -
AllowMove (
bool – get, set
)
Allow / Deny the ability to move the window on the screen, overridden when Locked= true -
AllowResize (
bool – get, set
)
Allow / Deny the ability to Resize the window, overridden when Locked= true -
Locked (
bool – get, set
)
Locked windows can not be moved or resized. When AllowLock = true this can be toggled from the options context menu -
OptionsMenuTooltip (
string – get, set
)
Allows for a runtime tooltip to be displayed when hovering the mouse over the options menu -
ResizeAreaTooltip (
string – get, set
)
Allows for a runtime tooltip to be displayed when hovering the mouse over the resize area -
Content (
VisualElement – get, set
)
Container for the content of the window, this is where you will add your Game UI visual elements to be displayed in the runtime window -
FooterToolbar (
VisualElement – get, set
)
Additional container for the footer area content of the window, this is an extra content area where you can add additional Game UI visual elements to be displayed in the runtime window footer - ContextMenuConfig (
object - ContextMenuConfig
) - Optional
Allows for a custom Options to be placed in the runtime context menu assigned to the window
Window Memory
The default is to have window memory off, so any window created will need to have its Window Memory setting set to true in order to save its location, size and open status. You MUST use the same name and parent ID when opening the window so that its data can be looked up in window memory.
The Window Frame Controller has a method to clear all window frame settings that is accessible at runtime from the settings window
(buttons on the demo window and the example escape menu window).
Note: The Window Memory is stored in the persistent data directory of the application and will not be cleared when the application is closed. This means that if you want to clear the memory you will need to do so manually or use the provided method in the Window Frame Controller.
To reopen all memory enabled windows that were open when playmode stopped, you make a single call to the WindowFrameController at the proper time in your start sequence.
WindowFrameController.Instance.ReopenWindows();
You can also pass in an optional float delay time to the ReopenWindows method.
WindowFrameController.Instance.ReopenWindows(float);
This will wait for the specified delay time before reopening the windows, allowing for any other initialization to complete first.
Defailt is 0.1 seconds if no value is passed in.