This page has been translated automatically.
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
API Reference
Integration Samples
C++ Plugins
Content Creation
Unigine Material Library
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.

Library's Namespace

By default, all variables, functions, classes, etc. 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, functions, classes, etc.
Source code (C++)
#include <Unigine.h>
#include <UnigineInterpreter.h>

using namespace Unigine;

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

int main(int argc,char **argv) {

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

	// Export a variable with a library prefix.

	// Initialize an engine. 
	Engine *engine = Engine::init(UNIGINE_VERSION,argc,argv);

	// Enter main loop.
	// Engine shutdown. 

	return 0;


An example is made by modifying the Simple.cpp sample, that can be found in the source/samples/Api/Systems/Simple/ folder of Unigine SDK or Evaluation kit.

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).

Source code (UnigineScript)
// my_world.cpp

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


The following console message will be printed:

Foo.i is 25
Last update: 2017-07-03
Build: ()