Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Sandworm (Experimental)
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Setting Up Development Environment
Usage Examples
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
Double Precision Coordinates
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

Library's Namespace

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.

By default, all variables and functions are exported from C++ in the global namespace. Libraries provide a convenient way to organize exposed functionality by adding a library's namespace. This namespace is used instead of Foo::Bar syntax that is not allowed for export.

Namespace Export Example#

  1. In order to use a library namespace, a library should be registered first via Unigine::Interpreter::addExternLibrary().
  2. After that, you can use a library namespace to register your variables and functions.
Source code (C++)
#include <UnigineEngine.h>
#include <UnigineInterpreter.h>
#include <UnigineInterface.h>

#include "AppSystemLogic.h"
#include "AppWorldLogic.h"
#include "AppEditorLogic.h"

using namespace Unigine;

// A variable within a namespace for export.
namespace Foo {
	int i = 25;

#ifdef _WIN32
	int wmain(int argc,wchar_t *argv[]) {
	int main(int argc,char *argv[]) {

	// Register a library in order to use a library namespace.

	// Export a variable with a library prefix.

	AppSystemLogic system_logic;
	AppWorldLogic world_logic;
	AppEditorLogic editor_logic;
	Unigine::EnginePtr engine(UNIGINE_VERSION,argc,argv);

	// Enter main loop.

	return 0;

Access from Scripts#

You can simply call the registered variables, functions, classes from Unigine scripts using the registered name. (If Foo library is not registered, the first dot in an object or function name is treated as an operator of class member access, which is wrong in our case).

In the init() function of the world script .usc file add the following:

Source code (UnigineScript)
// my_world.usc

int init() {
	/* ... code ... */

	log.message("Foo.i is %d\n",Foo.integer);

	/* ... code ... */



The following console message will be printed:

Foo.i is 25
Last update: 2020-04-21