This page has been translated automatically.
Recent news:
Table of contents:

UNIGINE 2.0 Alpha 2: Hotfixes and C# API

Introducing C# API

From now on it is possible to use C# for development of UNIGINE-powered applications, thereby involving the full power of IDEs. C# API provides functionality similar to C++ API. It allows you to:

  • Embed UNIGINE into C# applications.
  • Create external C# based App windows.
  • Call functions of the UnigineScript library from the C# code.
  • Export C# constant values and functions to UnigineScript.
  • Work with UnigineScript containers from the C# side.
  • Set callbacks.

Both x86 and x64 binaries with float and double coordinate precision are supported: all C# Wrapper libraries are compatible with double precision builds if the UNIGINE_DOUBLE definition is used.


  • The minimum supported C# version is 4.0.
  • The supported platforms are Windows and Linux.
  • Under Windows, Microsoft .NET Framework 4 and up is required. Under Linux, the latest Mono release version must be installed.

C# Wrapper Initialization

In your code, you should initialize the C# Wrapper by calling Wrapper.init() before Engine.init() in order to enable working with the engine before it is initialized: create packages, add functions to the interpreter and so on.

UnigineScript Interoperation

You can export functions from your C# code to UnigineScript. The exported function can have up to 8 arguments. However, you cannot export classes.

The function that is written in C# and must be exported to UnigineScript can receive arguments of the Variable type only. To get a value of the required type, use the corresponding getter functions.

You can also work with UnigineScript containers from the C# side. On the C# side, vectors and maps can be accessed via the ArrayVector and ArrayMap classes.

Export of constant values from C# to UnigineScript is also available.

See the examples in the source/csharp/samples/Api/Scripts/ folder for more details.


The callback functions can receive optional arguments of the int or IntPtr type that are used to store user data. IntPtr values can be wrapped in classes, for example:

Source code (C#)
IntPtr ptr;
// create a node and then create a Unigine object
Unigine.Object.create(new Node(ptr));

Managing Pointers

Each class of C# API has functions for managing pointers, which are managed in the same way as in C++. The full list of pointers is given in the C# API Reference article.

C# Samples

The C# samples are located in the source/csharp/samples/ folder. These samples are similar to the C++ API ones.

Each C# API sample folder contains the *.csproj MS Visual Studio C# project files in single precision.

Also there are 3 samples that demonstrate how to embed Unigine into a C# Windows Form application with:

  • Direct3D11 initialized via the SlimDX library (see the source/csharp/samples/App/D3D11SlimAppForm/ folder).
  • Direct3D11 initialized via the SharpDX library (see the source/csharp/samples/App/D3D11SharpAppForm/ folder).
  • OpenGL initialized via the OpenTK library (see the source/csharp/samples/App/GLTKAppForm/ folder).
These samples are located in the source/csharp/samples/App/ folder.

The samples can be compiled by typing make_x86 (or make_x64) -f Makefile.win32 on Windows (or Makefile on Linux) in the command prompt or via MS Visual Studio.


  • Added a render_simple_deferred console variable. If this console variable is set to 1, the additional SIMPLE_DEFERRED shader definition will be used. This definition is used inside the terrain shader for increasing the shading speed in case when the deferred buffer quality is not so important.
  • Improved triangulation provided by ObjectVolumeBox in corner cases.
  • The length parameter of the post_blur_radial shader has been renamed radius.
  • Added a new materials/procedural_01 stress sample. This sample can be used for comparing C++ / C# / UnigineScript performance.
  • The post_filter_wet material now creates an effect of flowing down water by default. Make sure that the auxiliary buffer is enabled.
  • Increased the maximum number of ObjectMeshSkinned bones per surface to 128.
  • Added the render / depth_00 sample. It shows how to use the post_deferred_depth postprocess material, which displays the linear depth.
  • Improved the render_composite material. Now the image can be displayed with the alpha buffer.
  • Added a new mesh_shadow_based material. It receives shadows casted from objects lightened by world, projected and omnidirectional lights and has adjustable light and shadow colors. Visibility of the shadow can also be modulated by the alpha channel.


  • The terrain shader performs fast prefetching which is based on diffuse texture sampling only. Prefetching can disable complex back-to-front blending calculations. It checks each terrain material to find the one that meets the following requirements:
    1. The material is checked as Overlap.
    2. Diffuse, normal and specular scales of the material are set to 1.
    3. The alpha channel of the material diffuse texture is equal to 1.
    If all of these conditions are observed, the lower materials will not be included in blending calculations. Otherwise, the complex shader computation will be performed. Prefetching of up to 8 upper materials is available.
  • Added a new stress sample with 48 active terrain materials (stress/terrain_02).
  • Increased the maximum number of per-terrain materials to 48.


Undo/Redo System

Undo/redo system has been completely refactored. Now there is a unified undo stack for all editor windows (except for Tracker for now) and plugins. Overall stability of the undo/redo operations has been drastically improved as well.


  • Fixed terrain grabber.
  • Fixed blending for diffuse brushes.
  • Added import of 3D texture masks.
  • Fixed updating of coarse textures.
  • Height limits for brushes are now calculated from the actual terrain size.
  • Fixed updating of arrays.
  • Fixed saving of terrain .settings files.
  • Landscape plugin: added an experimental fast mode for import.
  • Fixed compression and updating of textures.

City Import Plugin

  • All of the nodes are recalculated before generating.
  • Fixed nodes placement.
  • Fixed bug with duplicates.

File Dialog

  • Speeding up for large amount of files.
  • Added mesh info.
  • Fixed saving of LUT textures.
  • Added support for TIFF files.
  • Fixed saving of bookmarks.


  • Added the Edit -> Convert into NodeReference feature: it exports all selected nodes to the .node file and replaces them in the current world with the NodeReference to that file.
  • Improved the Edit -> Group selected feature.
  • Fixed terrain export to the Node Export plugin.
  • Fixed Randomizer plugin crashes.
  • Fixed Game Framework plugin.
  • Camera settings button is disabled if the camera is locked.
  • Async jobs can be interrupted now.
  • Added a world_init event.
  • Fixed focusing on objects with partially disabled surfaces.
  • Improved loading of the FBX files: meshes with joints, but without geometry, are now loaded as animations.
  • Improved the OpenFlight import plugin: added support for hidden and 2-sided flags of Face nodes.
  • Default speed presets have been changed: 5, 50, 500 units/s.
  • Editor camera position is stored on exit in the config file for each world. If there is no stored position in the config, the editor camera will be initialized with game camera settings.
  • Added a Mesh Combiner plugin: it combines surfaces of selected objects and creates a new mesh. Surfaces that have the same material assigned are combined into one and can be seen in the Surfaces tab of the resulting mesh.


  • Added support for the FBX file format to the MeshImport tool.
  • Added scene rotation around the Z axis by the mouse X axis in ResourceEditor. You can rotate the scene by using the horizontal mouse wheel or by pushing the vertical mouse wheel left or right.
  • Added a -define "extern_define" command line argument, which is used to pass an extern definition into the USC interpreter.



  • The call() container function can be used to call multiple user/extern functions with the same number of arguments by using their identifiers. For example, if you have an array that contains identifiers of different functions with the same number of arguments, you can call these functions at ones as follows:
    Source code (UnigineScript)
    void foo_1() { 
    	log.message(__FUNC__ + ": called\n");
    void foo_2() {
    	log.message(__FUNC__ + ": called\n");
    void foo_3() { 
    	log.message(__FUNC__ + ": called\n");
    // declare array of functions identifiers
    int functions[0];
    int init() {
    	// add the functions identifiers to the array
    	// call at ones all the functions stored in the array;
  • Added the anonymous function declaration in the style of C++ syntax. If you need to call a short function or a function that is not used elsewhere in the code (and therefore, the function name is not important), you can use the anonymous function. Anonymous functions always return the functions identifiers. For example, the following examples perform the same:
    Source code (UnigineScript)
    call( [](int a) { log.message("%d\n",a); }, 13);
    Source code (UnigineScript)
    print_13(int a) {
    The anonymous functions can be also used for async and array calls. The sample showing how to utilize anonymous functions inside the Async class: systems / socket_3.
  • Added the delete() container function that can receive two arguments. You can delete a specified number of container elements starting with a specified position. On the delete() function call, destructors will be called and the container elements in the specified range will be deleted.
  • You can write and read values with different endian notations to/from the Stream class. The default is the little-endian notation.
  • Improved the blend() function of the Image class. Now you can blend images of 32-bit floating point format.
  • Improved the function chaining. Now you can use this feature with the user defined classes in the script without casting the return value of the first function to the required type.
  • Changed the return type of the getCRC32() and getMD5() functions of the Buffer class. Now they return the hexadecimal string instead of the integer value.
  • Improved the addMeshSurface() function of the ObjectMeshStatic class. If the color array (or texture coordinates arrays) of the source or current mesh surface is empty, it will be filled with zero elements.


  • Added detection of the mouse horizontal scroll for WidgetScrollBox. You can now scroll horizontally by using the horizontal mouse wheel or by pushing the vertical mouse wheel when moving left or right.
  • Tooltips for WidgetTabBox are now positioned under the mouse cursor.
  • Added the size constraints for displaying the target image by WidgetDialogImage. The maximum image width and height is 8192 pixels. So now 1024×1024×32 texture arrays can be visualized in the image dialog window.
  • Fixed incorrect restoring of the permanent window focus under Win32.
  • The menu toggle key of the system script can be configured via systemSetToggle() / systemGetToggle() system script functions. These functions can be found in the data/core/scripts/system.h file.
  • Updated the widgets/ui_01 sample: now it shows how to declare and register widget callback functions in a single line of code.
  • Added the flags argument to the Unigine::Widget::Window / Dialog / DialogColor / DialogFile / DialogImage / DialogMessage constructors. This argument receives one of the InterfaceWindow flags.
  • Fixed the bug with inversion of a horizontal slider. If you scroll up the mouse wheel, the slider value will increase.
  • Fixed WidgetSpriteShader class. It will correctly call blending functions and set buffer mask parameters.

Mobile Platforms

  • Restored the Android platform support. Now there are two types of Android applications:
    • Native applications that have no Java code. These applications are useful for development and fast iterations. However, such applications are difficult to customize.
    • Activity-based applications that use Java code for OpenGLES and input handling as before. The number of arguments that can be passed from a system script to Java code (and vice versa) has been increased to 4. Moreover, support for double arguments has been added. A user can interact with the world and editor scripts via Java functions.
  • All Android-specific functions are available inside the engine.activity namespace instead of engine.tablet. The availability of these functions can be checked via the HAS_ACTIVITY definition.
  • Removed the Android client application and the FileClient plugin.
  • Added support for gcc-4.6 and gcc-4.8 for ARM-based Android builds.
  • Added an IPHONESDK environment variable, which is required for iOS builds. The variable must be equal to your iPhone SDK version, for example, "iPhoneOS8.1.sdk".



  • Added the AppGrabber plugin that grabs the current viewport each frame. This plugin can be used for streaming data to the different broadcasting applications.
  • Fixed the bug with the AppWall plugin crash on its start-up.
  • Added a new bool type to store console variables of the boolean type in the configuration file. Now the bool type is used instead of the int type. WARNING: It is recommended to delete your old .cfg files to re-configure projects in order to prevent errors.
  • Changed the behavior of the world_reload console command. Now it reloads the last world loaded via the world_load console command even if the loading operation has failed.
  • Added a config_readonly console variable. It blocks any attempts to write data to the configuration file.
  • Removed support for MS Visual Studio 2008.
  • Added a 3840×2160 (4K) video mode. To set it via console, specify the following: video_mode 8.
  • Increased the speed of saving RBG8 and RGBA8 images to DDS files in all of the dedicated applications.
Build: ()