This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
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
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
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.

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-04-19
Build: ()