This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
Tutorials

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: 2024-08-16
Build: ()