This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Animations-Related Classes
Containers
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
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы

Создание C# приложения

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 on Windows platform.Приложение на основе Unigine можно реализовать используя только C#, без использования UnigineScript. В этой статье описывается, как создать новое приложение C# на основе Unigine на платформе Windows.

Implementation by using the C# language is very similar to C++. Read the Creating C++ Application article to get basic principles.Реализация с использованием языка C# очень похожа на C ++. Прочтите статью Создание приложения C ++ , чтобы ознакомиться с основными принципами.

See AlsoСмотрите также#

  • Examples located in the <UnigineSDK>/source/csharp/samples/Api and <UnigineSDK>/source/csharp/samples/App foldersПримеры в папках <UnigineSDK>/source/csharp/samples/Api и <UnigineSDK>/source/csharp/samples/App.
  • The article on Setting Up Development Environment to learn more on how to prepare the development environmentСтатья о настройке среды разработки , чтобы узнать больше о том, как подготовить среду разработки.

Creating Empty C# ApplicationСоздание пустого приложения C##

It is very easy to start your own C# project by using UNIGINE SDK Browser:Начать свой собственный проект C# очень просто с помощью UNIGINE SDK Browser:

  1. Open the UNIGINE SDK Browser.Откройте браузер UNIGINE SDK.
  2. Go to the Projects tab and click CREATE NEW.
    Перейдите на вкладку Projects и нажмите CREATE NEW.
  3. Specify the following parameters:
    • Project name — specify the name of your project.Project name — specify the name of your project.
    • Location — specify the path to your project folder.Location — specify the path to your project folder.
    • SDK — choose the Unigine SDK.SDK — choose the Unigine SDK.
    • API+IDE — choose C# (.NET).API+IDE — choose C# (.NET).
    • Precision — specify the precision. In this example we will use double precision.Precision — specify the precision. In this example we will use double precision.
    Примечание
    Read more about these parameters in this article.Read more about these parameters in this article.
    Project name — specify the name of your project.Location — specify the path to your project folder.SDK — choose the Unigine SDK.API+IDE — choose C# (.NET).Precision — specify the precision. In this example we will use double precision.Read more about these parameters in this article.
    Укажите следующие параметры:
    • Project name — specify the name of your project.Project name - укажите название вашего проекта.
    • Location — specify the path to your project folder.Location - укажите путь к папке вашего проекта.
    • SDK — choose the Unigine SDK.SDK - выбираем Unigine SDK.
    • API+IDE — choose C# (.NET).API+IDE — выберите C# (.NET).
    • Precision — specify the precision. In this example we will use double precision.Precision - указать точность. В этом примере мы будем использовать двойную точность .
    Примечание
    Read more about these parameters in this article.Подробнее об этих параметрах читайте в этой статье .
  4. Click the Create New Project button. The project will appear in the projects list.
    Щелкните кнопку Create New Project. Проект появится в списке проектов.

You can run your project by clicking the Run button.Вы можете запустить свой проект, нажав кнопку Run.

Примечание
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#.По умолчанию в файле world script создаются WorldLight и PlayerSpectator. Вы можете оставить функции скрипта мира пустыми и создавать свои собственные источники света и проигрывателей с помощью C#.

Implementing C# LogicРеализация логики C##

In this section we will add logic to the empty C# application project and rotate the material ball that is created by default.В этом разделе мы добавим логику в пустой проект приложения C# и будем вращать material ball, который создается по умолчанию.

  1. In UNIGINE SDK Browser, choose your C# project created with the C# (.NET) option selected as API+IDE, and click the Open Editor button.В браузере UNIGINE SDK выберите проект C#, созданный с параметром C# (.NET), выбранным как API + IDE, и нажмите кнопку Open Editor.

    UnigineEditor will open.Откроется UnigineEditor.

  2. In UnigineEditor, create a new C# component via Asset Browser.

    Let's name it rotator.
    В UnigineEditor создайте новый компонент C# через Asset Browser.

    Давайте назовем его rotator.
  3. By double-clicking a created asset rotator.cs, it will open in the default IDE. Add the following code to this file.
    Исходный код (C#)
    public class rotator : Component
    {
    	public float angle = 30.0f;
    	
    	void Update()
    	{
    		// write here code to be called before updating each render frame
    		node.Rotate(0, 0, angle * Game.IFps);
    	}
    }
    All saved changes of the component source code make the component update with no compilation required when the Editor window gets focus.
    Если дважды щелкнуть созданный ассет rotator.cs, он откроется в IDE по умолчанию. Добавьте в этот файл следующий код.
    Исходный код (C#)
    public class rotator : Component
    {
    	public float angle = 30.0f;
    	
    	void Update()
    	{
    		// write here code to be called before updating each render frame
    		node.Rotate(0, 0, angle * Game.IFps);
    	}
    }
    Все сохраненные изменения исходного кода компонента приводят к обновлению компонента без необходимости компиляции, когда окно редактора получает фокус.
  4. Add this component to the material ball. Добавьте этот компонент в файл material ball.
  5. Run an instance of the application by clicking the Play button on the toolbar.
    Запустите экземпляр приложения, нажав кнопку Play на панели инструментов.

The component can be assigned to any node or nodes without changing anything in it.Компонент можно назначить любой ноде или нодам, ничего не меняя в нем.

Последнее обновление: 16.02.2023
Build: ()