This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

C# API Reference

Most functions and classes in C# API have the same names and behavior as in C++ API.

Notice
To work with C# API by using Mono on the Linux platform, the Mono should be installed this way.

Special Aspects of Pointers

You should take into account that each class of C# API has methods for managing pointers:

  • refPtr() - returns the reference counter.
  • getPtr() - returns the internal pointer.
  • checkPtr() - returns false if the internal pointer is IntPtr.Zero; otherwise, returns true.
  • clearPtr() - clears the pointer. After calling clearPtr(), getPtr() will return IntPtr.Zero and checkPtr() will return false.
  • destroyPtr() - destroys the pointer.

The pointers are managed in the same way as in C++.

Differences in Function Exporting

To export your function from C# to UnigineScript, you should use Interpreter.Function() with different postfixes instead of MakeExternFunction(). The postfix of Function shows the number of arguments (up to 8 arguments) and the type of return value:

  • no postfix - void.
  • i - int.
  • d - double.
  • f - float.
  • s - string.
  • v - Unigine.Variable (the same class as the C++ API Unigine::Variable class).

See also an example of function exporting.

Renderer Class

The C# API also has the Renderer class. This class allows you to get access to the specific pass of Rendering Sequence by overriding virtual methods of the Unigine.Renderer class.

Notice
In the C# API you can inherit from Renderer, Package and Plugin classes only once.

You can get access to the existing renderer instance by using get() function:

Source code(C#)
/* ... */
// get existing instance of the Renderer
Renderer renderer = Renderer.get();
/* ... */

Read about the C++ API Unigine::Renderer class which has the same methods and behavior as in the C# API.

Using References

You can add your .dll libraries to the C# project to use specific structures, classes and methods. If you use Visual Studio you can add NuGet packages to your solution by clicking Project -> Manage NuGet Packages...

View Documentation by Using Visual Studio

You can read the documentation of some of C# API methods by using the Object Browser in Visual Studio.

  1. In Visual Studio, click View -> Object Browser or press CTRL + W and then J.

    The Object Browser window will open. The Object Browser displays three panes: an Objects pane on the left, a Members pane on the upper right, and a Description pane on the lower right.

  2. Select the UnigineSharp_x64d (or UnigineSharp_x86d) object in the Object pane and choose the class you wish to view.

  3. Specify the member in the Members pane.
  4. If the description for chosen member exists, it will appear in the Description pane.

See Also

Last update: 03.07.2017
Build: ()