Window Framework for Unity UI Toolkit
Basic Usage
Implementing the Window Framework is very strait forward.
- Add a
UIDocument
to your scene - Select your panel settings (See the Unity Docs on Panel Settings for details)
- Assign the
WindowFrameworkRoot.uxml
as the source asset (located in theResources/WindowFramework
folder created by the asset installation) - Attach the
WindowFrameworkController.cs
file to the UIDocument component in your scene. - Click play and use the Inspector to generate an example window with no content.
Note
: You will need to create your content to fill the window with data and the runtime game UI functionality needed.
Simple Examples with Content
There is UI Toolkit example Content elements in the Demo/Scripts/ContentExamples
folder.
Included there is an example Log/Chat Window content visual element and can be used as starting point to add your own functionality.
To view the runtime examples
- Open the Demo scene in the
Assets/GarageWareGames/WindowFramework/Demo/Scenes
folder. - Click play to start the scene.
- In the Demo Control Window., use the buttons to open the examples
- A new window will open with a log/chat style content element.
You can also make the visual element custom control content as independent classes and then even if you do make a custom window type, you can just call the content class when needed allowing for dynamic and static window types being available for displaying the content.
Advanced Example of Dedicated Window Types
For a more advanced example of creating windows look in the Demo/Scripts/WindowExamples
folder.
There you will find the windows used in the demo scene.
These examples extend the WindowFrame class to define custom window types that can be added at runtime with a single line of code such as in the demo scene:WindowFrameController.Instance._rootElement.Add(new ToolbarWindow());
Custom window types are required if you want to enable the memory and reopen functionality since the custom window type code is assumed to also generate your custom content.
YouTube Video Tutorial Sorce Code
The source code for the YouTube video tutorial on the Window Framework can be found in the Demo/YouTubeVideoTutorials
folder.
This includes basic examples of how to use this asset to create a custom window type and content element, along with more advanced features like memory, reopen functionality, runtime tooltip and custom context menus for windows and content elements. This code is the same code used to create the videos on the Garage-Ware Games YouTube Channel.
Additional Resources
Read more about
Creating scalable and performant UI's with UI Toolkit on Unity's Website
Check out the Unity 6 UI Toolkit Updates on Unity's Blog