This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
UImGui (com.psydack.uimgui) is a Unity UPM package that wraps ImGui.NET for use in Unity projects. It supports Dear ImGui 1.90.1 with optional extensions (ImPlot, ImNodes, ImGuizmo), all three Unity render pipelines (Built-in, URP, HDRP), and both Unity input systems.
This is a Unity package, not a standalone C# project. There is no build script to run directly — it is compiled by the Unity Editor when added to a project.
Source/ Core runtime C# code
UImGui.cs Main MonoBehaviour — entry point, owns the frame loop
Utils/ UImGuiUtility (static context/events), RenderUtility, Constants
Platform/ IPlatform, InputManagerPlatform, InputSystemPlatform, PlatformBase
Renderer/ IRenderer, RendererMesh, RendererProcedural, RenderImGui (URP feature), RenderImGuiHDPass (HDRP)
Assets/ ScriptableObject assets: ShaderResourcesAsset, StyleAsset, FontAtlasConfigAsset, CursorShapesAsset, IniSettingsAsset
Data/ Context, UIOConfig, Font/, Shader/, SpriteInfo, Range
Texture/ TextureManager — maps Unity textures ↔ ImGui texture IDs
Freetype/ ImFreetype, ImFreetypeNative — FreeType font rasteriser bindings
Events/ FontInitializerEvent — UnityEvent wrapper for custom font setup
Plugins/ Native DLLs and managed DLLs for imgui, imguizmo, imnodes, implot
System.Runtime.CompilerServices.Unsafe.dll
Resources/ Default shaders and assets referenced at runtime
Sample/ Demo MonoBehaviours showing usage patterns
Editor/ Editor-only assembly (UImGui.Editor.asmdef)
The central class is UImGui (MonoBehaviour). Each instance owns:
- A
Context(wraps ImGui/ImPlot/ImNodes contexts +TextureManager) - An
IRenderer(Mesh or Procedural) - An
IPlatform(InputManager or InputSystem) - A
CommandBuffersubmitted each frame
Frame loop (DoUpdate):
TextureManager.PrepareFrame— sync texture registrationsIPlatform.PrepareFrame— feed mouse/keyboard/time toImGuiIOImGui.NewFrame/ layout events fired (UImGuiUtility.Layoutglobal + instanceLayout)ImGui.Render→IRenderer.RenderDrawLists→ writes intoCommandBuffer
Render pipeline integration:
- Built-in:
CommandBufferinjected viaCamera.AddCommandBuffer(CameraEvent.AfterEverything) - URP:
RenderImGui(ScriptableRendererFeature) executes the buffer - HDRP:
RenderImGuiHDPass(CustomPass) executes the buffer;Update()is skipped andDoUpdateis called from the pass instead
Compile-time defines (set automatically via versionDefines in UImGui.asmdef):
HAS_URP—com.unity.render-pipelines.universal >= 7.0.0HAS_HDRP—com.unity.render-pipelines.high-definition >= 7.0.0HAS_INPUTSYSTEM—com.unity.inputsystem >= 1.0.0
User-facing defines (set in Project Settings → Player → Script Define Symbols):
UIMGUI_REMOVE_IMPLOT— exclude ImPlotUIMGUI_REMOVE_IMNODES— exclude ImNodesUIMGUI_REMOVE_IMGUIZMO— exclude ImGuizmoUIMGUI_REMOVE_UNSAFE_DLL— exclude bundledSystem.Runtime.CompilerServices.Unsafe.dllwhen another package already provides it
Global events (requires Do Global Events = true on the UImGui component):
UImGuiUtility.Layout += OnLayout;
UImGuiUtility.OnInitialize += OnInitialize;
UImGuiUtility.OnDeinitialize += OnDeinitialize;Per-instance events:
_uimGuiInstance.Layout += OnLayout;Texture display:
IntPtr id = UImGuiUtility.GetTextureId(myTexture);
ImGui.Image(id, new Vector2(w, h));Custom fonts — assign a method matching void MyMethod(ImGuiIOPtr io) to the Font Custom Initializer field on the UImGui component.
System.Runtime.CompilerServices.Unsafe.dllconflicts with other packages — useUIMGUI_REMOVE_UNSAFE_DLLto resolve.- Font atlas crash has no fix; always use the callback approach for custom fonts.
- ImPlot is partially broken.
allowUnsafeCode = trueis required by the assembly definition.
Every delivered change must increment the version in package.json using SemVer based on the impact of the modification:
- MAJOR (
X.0.0): breaking API/behavior changes or compatibility breaks. - MINOR (
x.Y.0): backward-compatible new features. - PATCH (
x.y.Z): backward-compatible fixes, docs-only updates, and internal improvements.
Do not ship changes without updating package.json version accordingly.