Unigine.Splash Class
Controls the settings of the splash screen. Demonstration of it gives Unigine the time to load all world and compile shaders. For a splash screen a two-part texture can be set.
Function that displays a texture splash screen is usually divided into two parts — intro and outro, though there can be more of them; this is achieved with the yield operator. At this point the intro part is displayed. Intro parts usually consist of two images, which are gradually blended with different coefficients to show the progress.
See Also#
- A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/widgets/ folder:
- splash_00
- splash_01
- splash_03
- splash_04
Example
Here's a code example on how to add your own splash screens for application (system splash) and world loading (world splash).
Splash screens are defined inside the init() method of the SystemLogic class. Here we also display the system splash screen:
// AppSystemLogic.cs
/* ... */
public override bool Init()
{
// define new transform for splash screen
vec4 transform = new vec4(1.0f, 1.0f, 0.0f, 0.0f);
// enable the splash
Splash.Enabled = true;
// set transform to the system and world splash screens
Splash.SetWorldTransform(transform);
Splash.SetSystemTransform(transform);
// compute the aspect ratio to show corresponding texture
float aspect_ratio = (float)App.GetWidth() / (float)App.GetHeight();
// if the aspect ratio is 4:3 show these splash screens
// during application and world load
if (aspect_ratio < 1.5f) {
Splash.SetSystem("splash_4x3_system.png");
Splash.SetWorld("splash_4x3_world.png");
}
else {
// if the aspect ratio is 16:9 show these splash screens
// during application and world load
Splash.SetSystem("splash_16x9_system.png");
Splash.SetWorld("splash_16x9_world.png");
}
// set the text to be displayed on the system splash screen
// with a certain displacement along the X and Y axes
Splash.SetSystemText("<xy x=%50 dx=0 y=%50 dy=0/>SYSTEM SPLASH TEXT");
// set duration (in seconds) and display the system splash on application loading
int SplashDuration = 5;
DateTime begin = DateTime.Now;
while (DateTime.Now.Subtract(begin).TotalSeconds < SplashDuration)
Splash.RenderSystem((int)(DateTime.Now.Subtract(begin).TotalSeconds / SplashDuration * 100.0f));
// disable the splash
Splash.Enabled = false;
return 1;
}
/* ... */
World splash screen should be displayed in the init() method of the WorldLogic class:
// AppWorldLogic.cs
/* ... */
public override bool Init() {
// enable the splash
Splash.Enabled = true;
// set the text to be displayed on the world splash screen,
// specifying a color, a font, and a certain displacement along the X and Y axes
Splash.SetWorldText("<p align=\"center\"><font size=20 color=#FF0000FF>WORLD SPLASH TEXT</font></p>");
// set duration (in seconds) and display the world splash on world loading
int SplashDuration = 5;
DateTime begin = DateTime.Now;
while (DateTime.Now.Subtract(begin).TotalSeconds < SplashDuration)
Splash.RenderWorld((int)(DateTime.Now.Subtract(begin).TotalSeconds / SplashDuration * 100.0f));
// disable the splash
Splash.Enabled = false;
return 1;
}
/* ... */
Splash Class
Properties
bool IsEnabled#
Members
void SetColor ( vec4 color ) #
Sets the color of the text LOADING on the black background. This text is displayed, when a splash screen being called is cleared.Arguments
- vec4 color - Text color.
void SetSplash ( string name, int threshold = 0 ) #
Sets basic properties of a custom splash screen. This splash screen can be called from the script any time you need it. The splash screen can is a two-part texture.Arguments
- string name - Name of the file with the custom splash screen. If NULL (0) is passed, the splash screen is cleared.
- int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.
void SetSplashBackground ( vec4 color ) #
Sets the background color of the splash screen.Arguments
- vec4 color - Background color.
void SetSplashImage ( Image image, int threshold = 0 ) #
Sets an image for a custom splash screen. This splash screen can be called from the script any time you need it. The splash screen is a two-part texture shown according to the threshold.Arguments
- Image image - Image to be used as a custom splash screen.
- int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.
void SetSplashText ( string str ) #
Sets the text of the splash screen.Arguments
- string str - Text of the splash screen.
void SetSplashTransform ( vec4 transform ) #
Sets transformation of the splash.Arguments
- vec4 transform - Transformation of the splash.
void SetSystem ( string name, int threshold = 0 ) #
Sets basic properties of a system splash screen, which is displayed while resources like shaders and materials are being loaded on the engine start-up. The splash screen is a two-part texture.Arguments
- string name - Name of the file with the system splash screen. If NULL (0) is passed, the splash screen is cleared.
- int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.
void SetSystemBackground ( vec4 color ) #
Sets the background color of the system splash screen.Arguments
- vec4 color - Background color.
void SetSystemImage ( Image image, int threshold = 0 ) #
Sets an image for a system splash screen, which is displayed while resources like shaders and materials are being loaded on the engine start-up. The splash screen is a two-part texture shown according to the threshold.Arguments
- Image image - Image to be used as a system splash screen.
- int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.
void SetSystemText ( string str ) #
Sets the text of the system splash screen.Arguments
- string str - Text of the system splash screen.
void SetSystemTransform ( vec4 transform ) #
Sets transformation of the system splash.Arguments
- vec4 transform - Transformation of the system splash.
void SetWorld ( string name, int threshold = 0 ) #
Sets basic properties of a world splash screen, which is displayed while the world is being loaded. The splash screen is a two-part texture.Arguments
- string name - Name of the file with the world splash screen. If NULL (0) is passed, the splash screen is cleared.
- int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.
void SetWorldBackground ( vec4 color ) #
Sets the background color of the world splash screen.Arguments
- vec4 color - Background color.
void SetWorldImage ( Image image, int threshold = 0 ) #
Sets an image for a world splash screen, which is displayed while the world is being loaded. The splash screen is a two-part texture shown according to the threshold.Arguments
- Image image - Image to be used as a world splash screen.
- int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.
void SetWorldText ( string str ) #
Sets the text of the world splash screen.Arguments
- string str - Text of the world splash screen.
void SetWorldTransform ( vec4 transform ) #
Sets transformation of the world splash.Arguments
- vec4 transform - Transformation of the world splash.
void RenderInterface ( ) #
Renders a static splash screen. Such a splash screen does not display any progress.void RenderSplash ( int progress ) #
Renders a custom splash 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 splash screen texture.Arguments
- int progress - Progress of alpha blending between 2 splash 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) splash 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 RenderSystem ( int progress ) #
Renders a splash screen image, that is displayed by the system script reload, 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 splash screen texture.Arguments
- int progress - Progress of alpha blending between 2 splash 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) parts of 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 RenderWorld ( int progress ) #
Renders a splash screen image, that is displayed by the world load, 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 splash screen texture.Arguments
- int progress - Progress of alpha blending between 2 splash 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) parts of the texture are rendered. By the value of 0, the initial screen is loaded. By the value of 100, the final screen is loaded.