This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

UserInterface Class

Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.

The class is used to work with widgets that are created by loading a UI file.

Usage Examples#

The examples below show:

  • Loading a UserInterface from the *.ui file and accessing the widgets it stores.
  • Adding callbacks to these widgets.
  • Managing the UserInterface lifetime.

Managing Lifetime by the World#

The UserInterface is created on loading the world. When you reload or exit the world, or close the Engine window, the UserInterface is deleted.

Managing Lifetime by the Window#

The UserInterface is created in a separate window. When you close the window, the UserInterface is deleted as its lifetime is managed by this window. The console shows whether the window and UserInterface are deleted or not, whether the remove event is fired, and the message from the remove event handler (if it is).

After closing, the window can be re-created by pressing T.

Managing Lifetime by the Engine#

The lifetime of the UserInterface is managed by the Engine, so it is deleted on Engine shutdown. A Gui instance is set manually via the setGui() method.

The console shows whether the window and UserInterface are deleted or not, whether the remove event is fired, and the message from the remove event handler (if it is). After closing, the window can be re-created by pressing T.

See Also#

  • C++ API sample <UnigineSDK>/source/samples/Api/Widgets/UserInterface
  • C# API sample <UnigineSDK>/source/csharp/samples/Api/Widgets/UserInterface

UserInterface Class

Members


int getCallback ( int num, int callback ) #

Returns the number of a given callback function.

Arguments

  • int num - Widget number.
  • int callback

Return value

Callback number.

string getCallbackInstanceData ( int num ) #

Returns the callback instance data.

Arguments

  • int num - Widget number.

Return value

Instance data.

string getCallbackName ( int num ) #

Returns the name of a given callback function.

Arguments

  • int num - Widget number.

Return value

Callback function name.

string getCallbackStringData ( int num ) #

Returns the callback string data.

Arguments

  • int num - Widget number.

Return value

Callback string data (i.e. string data specified in the string parameter of the callback).

string getCallbackVariableData ( int num ) #

Returns the callback variable data.

Arguments

  • int num - Widget number.

Return value

Callback variable data (i.e. string data specified in the variable parameter of the callback).

Widget getCallbackWidgetData ( int num ) #

Returns the callback widget data.

Arguments

  • int num - Widget number.

Return value

Widget data (i.e. reference to a widget specified in the widget parameter of the callback).

int getNumCallbacks ( int num ) #

Returns the total number of callbacks for a given widget.

Arguments

  • int num - Widget number.

Return value

Number of callbacks.

int getNumWidgets ( ) #

Returns the number of associated widgets.

Return value

Number of associated widgets.

Widget getWidget ( int num ) #

Returns a widget with the given ID.

Arguments

  • int num - Widget ID.

Return value

Reference to widget with the given ID.

Widget getWidgetByName ( string name ) #

Returns a widget with the given name.

Arguments

  • string name - Widget name.

Return value

Widget with the given ID.

int getWidgetExport ( int num ) #

Returns a value indicating if a given widget is exported into a script (has export="1" flag in UI file).

Arguments

  • int num - Widget ID.

Return value

1 if the widget is exported; otherwise, 0.

string getWidgetName ( int num ) #

Returns widget name by ID.

Arguments

  • int num - Widget ID.

Return value

Widget name.

string getWidgetNext ( int num ) #

Returns the name of the widget, which will be focused next.

Arguments

  • int num - Widget number.

Return value

Widget name.

int findWidget ( string name ) #

Searches a widget by its name.

Arguments

  • string name - Widget name.

Return value

Returns the number of the widget if exists; otherwise, -1.

void updateWidgets ( ) #

Updates all widgets belonging to the user interface. This function should be called, for example, after change of the interface language.

void setGui ( Gui gui ) #

Sets a new Gui instance to be used for the UserInterface.

Arguments

  • Gui gui - Gui instance to be used for the UserInterface.

Gui getGui ( ) #

Returns a Gui instance for the UserInterface.

Return value

Gui instance currently used for the UserInterface.

void setLifetime ( int lifetime ) #

Sets the lifetime management type for the UserInterface. By default, the LIFETIME_ENGINE type is used.

Arguments

  • int lifetime

int getLifetime ( ) #

Returns the lifetime management type for the root of the UserInterface, or for the UserInterface itself (if it is not a child for another UserInterface).
Notice
Lifetime of each UserInterface in the hierarchy is defined by it's root. Thus, lifetime management type set for a child UserInterface that differs from the one set for the root is ignored.
Last update: 2024-01-11
Build: ()