This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and 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
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Working with Console

Calling a Console Command from Scripts

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

Source code (UnigineScript)
// 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 a script) 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 need to call engine.console.addCommand(). If you want your console command to take more than one argument, you need to implement separate functions per each number of arguments.
For example, we want our command to take one or two arguments.

Source code (UnigineScript)
// Create a console command
engine.console.addCommand("game_command","In-game console command","GameWorld::console");

// Implement a handler function with 1 argument
void console(string param1) {
	// do something
}

// Implement a handler function with 2 arguments
void console(string param1, string param2) {
	// do something
}

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

Disabling Console

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

Source code (UnigineScript)
// Disable the console
engine.console.setLock(1);
Last update: 03.07.2017
Build: ()