This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Режимы вывода изображения
Физика
Браузер SDK 2
Лицензирование и типы лицензий
Дополнения (Add-Ons)
Демонстрационные проекты
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
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
Учебные материалы

Dear ImGui

Dear ImGui C++ Integration#

UNIGINE integration with the Dear ImGui library v. 1.81 WIP (https://github.com/ocornut/imgui).

Integrating Into Your Project#

Integrating the Dear ImGui C++ sample into your project requires you to perform the following steps.

  1. Copy the following files from the sample project to your project:

    • The imgui folder — to the source/ folder
    • The ImGuiImpl.cpp and ImGuiImpl.h files — to the source/ folder
    • The data/imgui.basemat file — to the data/ folder
  2. In Visual Studio, add all files copied to the source/ folder to your project (Project -> Add Existing Item...).
  3. To display the sample menu in your application, add the following lines in the corresponding sections of source/AppSystemLogic.cpp:

    Source code (C++)
    #include <UnigineWorld.h>
    #include <UnigineControls.h>
    #include <UnigineInput.h>
    
    #include "ImGuiImpl.h"
    
    using namespace Unigine;
    
    	
    int AppSystemLogic::init()
    {
    	Unigine::Engine::get()->setBackgroundUpdate(Engine::BACKGROUND_UPDATE_RENDER_NON_MINIMIZED);
    
    	// initialize ImGui backend, set up the Engine
    	ImGuiImpl::init();
    
    	return 1;
    }
    
    int AppSystemLogic::update()
    {
    	EngineWindowPtr main_window = WindowManager::getMainWindow();
    	if (!main_window)
    	{
    		Engine::get()->quit();
    		return 1;
    	}
    
    	ImGuiImpl::newFrame();
    
    	// feel free to use ImGui API here...
    	ImGui::ShowDemoWindow();
    
    	ImGuiImpl::render();
    	return 1;
    }
    
    int AppSystemLogic::shutdown()
    {
    	ImGuiImpl::shutdown();
    
    	return 1;
    }
Notice

The sample uses ImGui version 1.81.0 WIP with a customized imconfig.h file. If you want to use another version, replace the following commented line in the imconfig.h file that you use:

Source code
//#define ImDrawIdx unsigned int

with this:

Source code
#define ImDrawIdx int

Otherwise, you'll get a compilation error.

Building the Project#

When creating a release build, add the absolute and the relative path for imgui.basemat as shown below:


SDK Path: <SDK_INSTALLATION>source\samples\3rdparty\ImGui

Dear ImGui C# Integration#

UNIGINE integration with the Dear ImGui library v. 1.86 (https://github.com/ocornut/imgui). Implemented on the basis of the ImGui.NET wrapper (https://github.com/mellinoe/ImGui.NET).

Integrating Into Your Project#

Integrating the Dear ImGui C# sample into your project requires you to perform the following steps.

  1. Add ImGui libraries using either of the following variants:

    • Manually: copy the cimgui.dll and ImGui.NET.dll files from the sample folder to the bin/ folder of your project.
    • In Visual Studio Code, open the terminal and type dotnet add package ImGui.NET -v 1.86.0.
    • In Visual Studio, select Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution..., find ImGui.NET wrapper and install it (the sample uses version 1.86.0).

      Installing ImGui.NET wrapper in Visual Studio

  2. Copy the data/imgui.basemat file to the data/ folder of your project.
  3. Copy the ImGuiImpl.cs file to the source/ folder of your project.
  4. Add ImGuiImpl.cs to <Project_Name>.csproj in the root directory of the project:

    Source code
    <Compile Include="source\ImGuiImpl.cs" />
  5. Add the ImGui.NET.dll library to the Reference in <Project_Name>.csproj and make sure to specify the HintPath:

    Source code
    <ItemGroup>
    	<Reference Include="ImGui.NET">
    		<HintPath>bin\ImGui.NET.dll</HintPath>
    	</Reference>
    </ItemGroup>
  6. In <Project_Name>.csproj, add the possibility to work with Unsafe blocks:

    Source code
    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
  7. In source/AppSystemLogic.cs, add the directive and the following code in the corresponding methods.

    Source code (C#)
    using ImGuiNET;
    
    	
    	public override bool Init()
    		{
    			ImGuiImpl.Init();
    			return true;
    		}
    
    		public override bool Update()
    		{
    			ImGuiImpl.NewFrame();
    
    			// feel free to use ImGui API here...
    			ImGui.ShowDemoWindow();
    
    			ImGuiImpl.Render();
    
    			return true;
    		}
    		public override bool Shutdown()
    		{
    			ImGuiImpl.Shutdown();
    			return true;
    		}
Notice

The sample uses ImGui version 1.86.0 with a customized imconfig.h file. If you want to use another version, replace the following commented line in the imconfig.h file that you use:

Source code
//#define ImDrawIdx unsigned int

with this:

Source code
#define ImDrawIdx int

Otherwise, you'll get a compilation error.

Building the Project#

When creating a build, add the absolute and the relative path for cimgui.dll and imgui.basemat as shown below:


SDK Path: <SDK_INSTALLATION>source\csharp\samples\3rdparty\ImGui
Last update: 13.12.2024
Build: ()