This page has been translated automatically.
Setting Up Development Environment
High-Level Systems
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
Double Precision Coordinates
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
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.

Creating C# Application

A Unigine-based application can be implemented by means of C# only, without using UnigineScript. This article describes how to create a new Unigine-based C# application in Visual Studio on Windows platform.

Implementation by using the C# language is very similar to C++. Read the Creating C++ Application article to get basic principles.

C# is supported on Windows only.

See Also

  • Examples located in the <UnigineSDK>/source/csharp/samples/Api and <UnigineSDK>/source/csharp/samples/App folders.
  • The article on Setting Up Development Environment to learn more on how to prepare the development environment.

Creating Empty C# Application

It is very easy to start your own C# project by using UNIGINE SDK Browser:

  1. Open the UNIGINE SDK Browser.
  2. Go to the Projects tab and click CREATE NEW.

  3. Specify the following parameters:

    • Project - specify the name of your project.
    • Project Path - specify the path to your project folder.
    • SDK - choose the Unigine SDK.
    • API - here choose C# (Visual Studio) to start working with the C# API.
    • Architecture - specify the architecture of your target platform.
    • Precision - specify the precision. In this example we will use double precision.
    Read more about these parameters in this article
  4. Click the Create New Project button. The project will appear in the projects list.

You can run your project by clicking the Run button.

By default, in the world script file a WorldLight and a PlayerSpectator are created. You can leave functions of the world script empty, and create your own lights and players by using C#.

Implementing C# Logic

In this section we will add logic to the empty C# application project.

The following example shows how to rotate the material ball that was created by default in your project.

  1. In the Unigine SDK Browser, choose your C# project and click the Edit Code button.

    Visual Studio will be opened.
  2. In Visual Studio, write the following code in your project's AppWorldLogic.cs file.
    Source code (C#)
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Unigine;
    namespace UnigineApp
    	class AppWorldLogic : WorldLogic
    		// define pointer to node
    		Node node;
    		public AppWorldLogic()
    		public override int init()
    			// find the material ball node by its name
    			Editor e = Editor.get();
    			node = e.getNodeByName("material_ball");
    			return 1;
    		public override int shutdown()
    			return 1;
    		public override int destroy()
    			return 1;
    		public override int update()
    			Game game = Game.get();
    			// set the transformation to the node
    			float ifps = game.getIFps();
    			double angle = ifps * 90.0f;
    			dmat4 transform = node.getTransform() * MathLib.rotateZ(angle);
    			return 1;
    		public override int render()
    			return 1;
    		public override int flush()
    			return 1;
    		public override int save(Stream stream)
    			return 1;
    		public override int restore(Stream stream)
    			return 1;
  3. Build your project by clicking Build -> Build Solution in Visual Studio or press F7.

  4. Start your project by clicking Debug -> Start in a proper mode in Visual Studio.

To run your project from SDK Browser, specify the path to the .exe file of your C# project in SDK Browser by customizing Run Project
Last update: 2017-07-03
Build: ()