This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
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
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Working with Console

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 UnigineScipt (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.

Calling a Console Command from Code#

To call a console command from any of the scripts, you should call engine.console.run().

Source code (UnigineScript)
// For example, to show messages:
// For example, to show messages:
engine.console.run("show_messages 1");

Console commands (regardless of whether they were typed in the console or called from the code) cannot not be executed in the middle of the frame. Instead, they are executed in the beginning of the next frame not to interrupt the current rendering process and physics calculations.

Creating a Console Command#

To create a custom console command, you should:

  1. Implement a function that will be run on the console command call. If you want your console command to take more than one argument, you need to implement a separate function per each number of arguments.
  2. Call engine.console.addCommand() to add a new command.
In the example below, a new command takes no arguments or one argument:
Source code (UnigineScript)
// a script function to be executed for no arguments input
void console() {
	log.message("console_command with no arguments has been called\n");
}

// a script function to be executed for 1 argument input
void console(string arg) {
	log.message("console_command with 1 argument has been called\n Argument: %s\n", arg);
}

int init() {
	// create a console command
	engine.console.addCommand("console_command","console_command description","console");

	return 1;
}
To check the result, run the added command:
Source code
Unigine~# console_command
console_command with no arguments has been called

Unigine~# console_command arg
console_command with 1 argument has been called
Argument: arg

You can also remove custom console commands via engine.console.removeCommand().

Creating a Console Variable#

Notice
UnigineScript API doesn't provide the ability to add console variables.

Disabling Console#

To disable console (for example, for an application production version), you need to call engine.console.setLock().

Source code (UnigineScript)
// disable the console
engine.console.setLock(1);
Last update: 2020-07-31
Build: ()