UI script||doc135361

September 20, 2022

Introduction

UI scripts, as the name suggests, are code scripts mounted under the UI interface, and will only run on the client. In the interface editor, an interface will only mount a UI script, or a UI script under a layout file. Through this script, we can access properties, functions or events of other sub-controls under this layout.


UI scripts can only be accessed and created on the client side


Entry of UI scripts

UI scripts do not need us to be created manually. As long as a new interface is created in the interface management of the interface editor, a UI script associated with this interface will be automatically created, and the entry of the UI script can be seen on the property bar of this interface:


Execution timing of UI scripts

When we display an interface in the screen window, the UI script under the interface is loaded.


How to get other controls under the interface

When the UI script is executed, in the script we can passselforMto get the root node of the interfaceRoot. The easiest way to get child controls is to use the operator "." to getRootThe child controls under the node, pay attention to "."It is not a recursive search, only the sub-controls under the current node can be obtained, but the sub-controls under the sub-control node cannot be obtained. At the same time, we can also obtain the sub-controls by using the access function. For details, seeGUI;s introduction.