Skip to content
 
 

Repository files navigation

ImGui.NET.4Unity

ImGui.NET.4Unity is a maintained ImGui.NET fork focused on Unity integration scenarios.

Current Dear ImGui / ImGui.NET version: 1.92.9.0

It provides .NET bindings for:

  • Dear ImGui via cimgui
  • ImPlot (cimplot)
  • ImNodes (cimnodes)
  • ImGuizmo (cimguizmo)
  • Additional native variants used by this fork (cimplot3d, cimnodes_r, cimguizmo_quat, cimCTE)

Project goal

This repository is used to keep native/runtime bindings updated and then propagate those updates to:

In short: this is the update workspace used to bring newer ImGui ecosystem native libs and generated bindings into psydack/uimgui.

How the repo works

Most of the API surface is generated from native definition JSON files.

  • Native binaries are stored under deps/<lib>/<rid>/
  • Native API JSON definitions are stored under src/CodeGenerator/definitions/<lib>/
  • Generated C# bindings are emitted into each project Generated/ folder

Projects in src/:

  • ImGui.NET
  • ImPlot.NET
  • ImPlot3D.NET
  • ImNodes.NET
  • ImNodesR.NET
  • ImGuizmo.NET
  • ImGuizmoQuat.NET
  • CimCTE.NET
  • CodeGenerator
  • Sample programs

Update native dependencies

PowerShell:

./download-native-deps.ps1
./download-native-deps.ps1 -tag <release-tag>
./download-native-deps.ps1 -localRoot ../ImGui.NET-nativebuild -configuration Release

Bash:

./download-native-deps.sh
./download-native-deps.sh <release-tag>

By default, scripts download from:

  • https://github.com/psydack/ImGui.NET-nativebuild

They refresh:

  • Native binaries in deps/
  • definitions.json, structs_and_enums.json, and variants.json in src/CodeGenerator/definitions/

The local-root mode copies available Windows builds without deleting the committed ARM64, Linux, or macOS artifacts. A public release must only be assembled after the native CI artifacts for all five platforms have been synchronized.

Regenerate bindings

Build and run the generator after updating native dependencies:

dotnet restore src
dotnet build src

# ImGui
bin/Release/CodeGenerator/net8.0/CodeGenerator.exe "src/ImGui.NET/Generated"

# ImPlot
bin/Release/CodeGenerator/net8.0/CodeGenerator.exe "src/ImPlot.NET/Generated" cimplot

# ImNodes
bin/Release/CodeGenerator/net8.0/CodeGenerator.exe "src/ImNodes.NET/Generated" cimnodes

# ImGuizmo
bin/Release/CodeGenerator/net8.0/CodeGenerator.exe "src/ImGuizmo.NET/Generated" cimguizmo

# ImPlot3D
bin/Release/CodeGenerator/net8.0/CodeGenerator.exe "src/ImPlot3D.NET/Generated" cimplot3d

# ImNodesR
bin/Release/CodeGenerator/net8.0/CodeGenerator.exe "src/ImNodesR.NET/Generated" cimnodes_r

# ImGuizmoQuat
bin/Release/CodeGenerator/net8.0/CodeGenerator.exe "src/ImGuizmoQuat.NET/Generated" cimguizmo_quat

# CimCTE
bin/Release/CodeGenerator/net8.0/CodeGenerator.exe "src/CimCTE.NET/Generated" cimCTE

The generator removes stale *.gen.cs files before writing a new API surface. Review deleted generated types as carefully as additions because Dear ImGui may have removed or renamed them.

Validate and propagate

dotnet restore src
dotnet build src/ImGui.NET.sln -c Release --no-restore
dotnet pack src/ImGui.NET/ImGui.NET.csproj -c Release --no-build

After all five native platforms are synchronized and the managed build passes, update UImGui with:

../uimgui/sync-imgui.ps1 -BindingsRoot . -Configuration Release

Windows DLLs are expected to use static MSVC runtime linkage, Control Flow Guard, reproducible linking, and version metadata. Do not publish a package containing native binaries from different native-stack commits.

FreeType and custom_assert examples

FreeType font loader (C#)

ImGuiIOPtr io = ImGui.GetIO();
IntPtr freeTypeLoader = ImGui.GetFontLoader();
if (freeTypeLoader != IntPtr.Zero)
{
    io.Fonts.SetFontLoader(freeTypeLoader);
    io.Fonts.FontLoaderFlags = (uint)ImGuiFreeTypeLoaderFlags.LightHinting;
}

custom_assert behavior (C# runtime toggle)

ImGuiIOPtr io = ImGui.GetIO();
io.ConfigErrorRecoveryEnableAssert = true;

With native builds compiled with custom_assert, assertion failures are routed by the native assert hook.

custom_assert hook (native build side)

// Example at native build integration layer:
// #define IM_ASSERT(_EXPR) CustomAssert((_EXPR), #_EXPR, __FILE__, __LINE__)

Build

dotnet restore src
dotnet build src

ImGui.NET currently targets:

  • netstandard2.0
  • net6.0
  • net8.0

Notes

  • Generated/*.gen.cs files are generated artifacts and should not be edited manually.
  • Manual wrapper behavior should be changed in *.Manual.cs files.

About

An ImGui wrapper for .NET. for Unity

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages