September 20, 2022


Global singleton

Client only


The UI is a global singleton object in the game script that helps manage the GUI. It creates GUI instances by using the layout designed in the UI editor and manages these instances during the game. The UI class provides important operations such as creating new GUI instances, obtaining existing instances, and showing instances to players. It can also directly create a single control instance without relying on the layout file, allowing developers to flexibly process game business at runtime.


The layout is a file that describes the GUI presentation style and does not contain any functional logic for GUI operation. The core of the GUI is "control". By adjusting the size and position of the control, combining the parent-child hierarchical relationship between the controls, and the controls with unique functions such as pictures, text, progress bar, etc., the GUI layout is created and designed. Use the interface editor to design your own GUI layout, such as HUD in the game, menu or any other interface that you want to provide users with observation and interaction in the game.

As mentioned at the beginning of the above, the layout is only a description of the GUI display style. In the actual game, a layout may have one GUI instance, or multiple GUI instances may use the same layout. If you know object-oriented programming, you can imagine that the layout corresponds to the class, and the GUI instance corresponds to the instance of the class; If you don't know much about programming, you can take a look at this metaphor (which is often used to explain what a class is for people who first come into contact with programming): we know that a design drawing is required to produce a car, and the same design drawing can be used repeatedly to produce thousands of the same vehicles. Hopefully, this will help you understand the relationship between layout and GUI instances.


Window Root [ReadOnly]
GUI root node when the game is running. Only GUI instances that are direct or indirect sub levels of root will be displayed in the game


Window CreateGUIWindowstring layoutPath, string instanceName )
Create a GUI instance according to the layout path and return
Window CreateGUIWidgetWidgetType widgetType )
Create a control of the specified type, and create a basic control by default