LoadingScreen Class
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.
A singleton that controls the settings of the loading screen. Demonstration of it gives Unigine the time to load all world nodes and resources. You can also show your own loading screen when needed.
A loading screen displays a texture that is usually divided into two parts stacked vertically — the initial and final pictures — which are gradually blended from the beginning up to the end of loading to show the progress. Blending is performed based on the alpha channel of the outro (lower) part of the texture so pseudo-animation can be created using the alpha channel: regions of the lower half with small alpha values will be shown first, regions with larger alpha values will be shown last.
See Also#
- A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/widgets/ folder:
- loading_screen_00
- loading_screen_01
- loading_screen_04
- Quick Video Guide: How To Customize Loading Screens.
LoadingScreen Class
Members
void engine.loading_screen.setEnabled ( int enabled ) #
Specifies if manual rendering of the loading screen can be started or should be stopped.setEnabled() is used only together with the corresponding render functions (render()). It cannot be used to enable or disable rendering of the loading screen during the initialization stage of the engine.
Arguments
- int enabled - 1 to enable manual rendering of a custom loading screen; 0 to disable.
int engine.loading_screen.isEnabled ( ) #
Returns a value indicating if manual rendering of a loading screen is allowed.Return value
1 if the rendering of the loading screen is enabled; otherwise, 0.void engine.loading_screen.setThreshold ( int threshold ) #
Sets the amount of blur in the alpha channel when interpolating between states of the loading screen.By default, the Threshold value is set to 16.
Arguments
- int threshold - amount of blur in the [0, 255] range.
int engine.loading_screen.getThreshold ( ) #
Returns the amount of blur in the alpha channel when interpolating between states of the loading screen.Return value
amount of blur.void engine.loading_screen.setTexturePath ( string path ) #
Sets the path to a texture for custom loading screens.Arguments
- string path - Path to a file with the custom loading screen texture. If NULL (0) is passed, no texture will be used.
string engine.loading_screen.getTexturePath ( ) #
Returns the path to the texture for loading screens.Return value
Path to the texture of the loading screens.void engine.loading_screen.setImage ( Image image ) #
Sets an image for a custom loading screen.Arguments
- Image image - Image to be used as a custom loading screen.
void engine.loading_screen.setTransform ( vec4 transform ) #
Sets transformation of the loading screen texture.Arguments
- vec4 transform - Transformation of the loading screen texture:
- Texture size multiplier.
- Window size multiplier.
- Horizontal position in the [0.0f, 1.0f] range.
- Vertical position in the [0.0f, 1.0f] range.
vec4 engine.loading_screen.getTransform ( ) #
Returns transformation of the loading screen texture.Return value
transformation of the texture.void engine.loading_screen.setBackgroundColor ( vec4 color ) #
Sets the background color of the loading screen.Arguments
- vec4 color - Background color.
vec4 engine.loading_screen.getBackgroundColor ( ) #
Returns the background color of loading screens.Return value
Background color.void engine.loading_screen.setText ( string text ) #
Sets the text of the loading screen.Arguments
- string text -
Text of the loading screen. Can be either a plain or rich text. A number of aliases is available:
- UNIGINE_COPYRIGHT — the UNIGINE copyright text.
- UNIGINE_VERSION — the current UNIGINE version.
- LOADING_PROGRESS — the loading progress going from 0 to 100.
- LOADING_WORLD — the world being loaded (if any).
string engine.loading_screen.getText ( ) #
Returns the text of the loading screen.Return value
Text of the loading screen.void engine.loading_screen.setFontPath ( string path ) #
Sets the path to the font used to render the text.Arguments
- string path - Path to the font (True Type Font).
string engine.loading_screen.getFontPath ( ) #
Returns the path to the font used to render the text.Return value
Path to the font.void engine.loading_screen.renderInterface ( ) #
Renders a static loading screen. Such a screen does not display any progress.void engine.loading_screen.render ( ) #
Renders the loading screen in the current progress state and with the current stage message.void engine.loading_screen.render ( int progress ) #
Renders a custom loading screen in a given progress state. Use this function in a loop to create a gradual change between the initial (upper opaque part) and the final states (bottom transparent part) of the loading screen texture.Arguments
- int progress - Progress of alpha blending between 2 screens stored in the texture. The value in range [0;100] sets an alpha channel threshold, according to which pixels from the initial (opaque) or final (transparent) screen in the texture are rendered. By the value of 0, the initial screen is loaded. By the value of 100, the final screen is loaded.
void engine.loading_screen.render ( int progress, string message ) #
Renders a custom loading screen in a given progress state and prints a given message. Use this function in a loop to create a gradual change between the initial (upper opaque part) and the final states (bottom transparent part) of the loading screen texture, while printing a custom loading stage.Arguments
- int progress - Progress of alpha blending between 2 loading screens stored in the texture. The value in range [0;100] sets an alpha channel threshold, according to which pixels from the initial (opaque) or final (transparent) loading screen in the texture are rendered. By the value of 0, the initial screen is loaded. By the value of 100, the final screen is loaded.
- string message - message to print representing the loading stage.
void engine.loading_screen.renderForce ( ) #
Renders the loading screen regardless of whether the manual rendering is allowed or not.void engine.loading_screen.renderForce ( string message ) #
Renders the loading screen regardless of whether the manual rendering is allowed or not and prints a given message.Arguments
- string message - message to print that represents the loading stage.
int engine.loading_screen.getProgress ( ) #
Returns the current progress state.Return value
Progress state in the [0, 100] range.string engine.loading_screen.getMessage ( ) #
Returns the text message representing the current loading stage.Return value
Loading message.void engine.loading_screen.setMessageLoadingWorld ( string world ) #
Sets a message to be displayed on world loading.Arguments
- string world - Message on world loading. The text aliases are also supported.
string engine.loading_screen.getMessageLoadingWorld ( ) #
Returns the current message displayed on world loading.Return value
Message on world loading.void engine.loading_screen.setMessageShadersCompilation ( string compilation ) #
Sets a message to be displayed on shaders compilation.Arguments
- string compilation - Message on shaders compilation. The text aliases are also supported.
string engine.loading_screen.getMessageShadersCompilation ( ) #
Returns the current message displayed on shaders compilation.Return value
Message on shaders compilation.Last update:
2021-12-13
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)