Code Monkey home page Code Monkey logo

uimgui's Introduction

UImGui

GitHub tag (latest by date)
(ImGui library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out.)

UImGui (Unity ImGui) is an UPM package for the immediate mode GUI library using ImGui.NET. This project is based on RG.ImGui project. This project use FreeType as default renderer.

Using imgui 1.90.1


What is Dear ImGui?

Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).

Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.

Motivation

To update (using ImGui.Net.dll) easier and often.

Features

Feature RG UImGui
IL2CPP ✔️
Windows ✔️ ✔️
Linux ✔️ ✔️
MacOS ✔️ ✔️
Custom Assert ✔️
Unity Input Manager ✔️ ✔️
Unity Input System ✔️ ✔️
Docking ✔️
RenderPipeline Built in ✔️ ✔️
RenderPipeline URP ✔️
RenderPipeline HDRP ✔️
Renderer Mesh ✔️ ✔️
Renderer Procedural ~ ✔️
FreeType ~ WIP
Image / Texture ✔️
ImNodes WIP
ImGuizmo WIP
ImPlot WIP

Usage

Samples

It has a demo script called ShowDemoWindow inside UImGui/Sample folder.

You can subscribe to global layout or for a specific UImGui context: If choose to use global, don't to forget to set Do Global Events to true on UImGui instance.

using UImGui;
using UnityEngine;

public class StaticSample : MonoBehaviour
{
	private void Awake()
	{
		UImGuiUtility.Layout += OnLayout;
		UImGuiUtility.OnInitialize += OnInitialize;
		UImGuiUtility.OnDeinitialize += OnDeinitialize;
	}

	private void OnLayout(UImGui.UImGui obj)
	{
		// Unity Update method. 
		// Your code belongs here! Like ImGui.Begin... etc.
	}

	private void OnInitialize(UImGui.UImGui obj)
	{
		// runs after UImGui.OnEnable();
	}

	private void OnDeinitialize(UImGui.UImGui obj)
	{
		// runs after UImGui.OnDisable();
	}

	private void OnDisable()
	{
		UImGuiUtility.Layout -= OnLayout;
		UImGuiUtility.OnInitialize -= OnInitialize;
		UImGuiUtility.OnDeinitialize -= OnDeinitialize;
	}
}

To use instance instead a global UImGui, use like this.

using UnityEngine;

public class InstanceSample : MonoBehaviour
{
	[SerializeField]
	private UImGui.UImGui _uimGuiInstance;

	private void Awake()
	{
		if (_uimGuiInstance == null)
		{
			Debug.LogError("Must assign a UImGuiInstance or use UImGuiUtility with Do Global Events on UImGui component.");
		}

		_uimGuiInstance.Layout += OnLayout;
		_uimGuiInstance.OnInitialize += OnInitialize;
		_uimGuiInstance.OnDeinitialize += OnDeinitialize;
	}

	private void OnLayout(UImGui.UImGui obj)
	{
		// Unity Update method. 
		// Your code belongs here! Like ImGui.Begin... etc.
	}

	private void OnInitialize(UImGui.UImGui obj)
	{
		// runs after UImGui.OnEnable();
	}

	private void OnDeinitialize(UImGui.UImGui obj)
	{
		// runs after UImGui.OnDisable();
	}

	private void OnDisable()
	{
		_uimGuiInstance.Layout -= OnLayout;
		_uimGuiInstance.OnInitialize -= OnInitialize;
		_uimGuiInstance.OnDeinitialize -= OnDeinitialize;
	}
}

Sample code

[SerializeField]
private float _sliderFloatValue = 1;

[SerializeField]
private string _inputText;

// Add listeners, etc ...

private void OnLayout(UImGui.UImGui obj)
{
	ImGui.Text($"Hello, world {123}");
	if (ImGui.Button("Save"))
	{
		Debug.Log("Save");
	}

	ImGui.InputText("string", ref _inputText, 100);
	ImGui.SliderFloat("float", ref _sliderFloatValue, 0.0f, 1.0f);
}

image

[SerializeField]
private Vector4 _myColor;
private bool _isOpen;

private void OnLayout(UImGui.UImGui obj)
{
	// Create a window called "My First Tool", with a menu bar.
	ImGui.Begin("My First Tool", ref _isOpen, ImGuiWindowFlags.MenuBar);
	if (ImGui.BeginMenuBar())
	{
		if (ImGui.BeginMenu("File"))
		{
			if (ImGui.MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ }
			if (ImGui.MenuItem("Save", "Ctrl+S")) { /* Do stuff */ }
			if (ImGui.MenuItem("Close", "Ctrl+W")) { _isOpen = false; }
			ImGui.EndMenu();
		}
		ImGui.EndMenuBar();
	}

	// Edit a color (stored as ~4 floats)
	ImGui.ColorEdit4("Color", ref _myColor);

	// Plot some values
	float[] my_values = new float[] { 0.2f, 0.1f, 1.0f, 0.5f, 0.9f, 2.2f };
	ImGui.PlotLines("Frame Times", ref my_values[0], my_values.Length);


	// Display contents in a scrolling region
	ImGui.TextColored(new Vector4(1, 1, 0, 1), "Important Stuff");
	ImGui.BeginChild("Scrolling");
	for (int n = 0; n < 50; n++)
		ImGui.Text($"{n}: Some text");
	ImGui.EndChild();
	ImGui.End();
}

image

Image Sample

[SerializeField]
private Texture _sampleTexture;

private void OnLayout(UImGui.UImGui obj)
{
	if (ImGui.Begin("Image Sample"))
	{
		System.IntPtr id = UImGuiUtility.GetTextureId(_sampleTexture);
		Vector2 size = new Vector2(_sampleTexture.width, _sampleTexture.height)
		ImGui.Image(id, size);

		ImGui.End();
	}
}

image

Custom UserData

[Serializable]
private struct UserData
{
	public int SomeCoolValue;
}

[SerializeField]
private UserData _userData;
private string _input = "";

// Add Listeners... etc.

private unsafe void OnInitialize(UImGui.UImGui uimgui)
{
	fixed (UserData* ptr = &_userData)
	{
		uimgui.SetUserData((IntPtr)ptr);
	}
}

private unsafe void OnLayout(UImGui.UImGui obj)
{
	if (ImGui.Begin("Custom UserData"))
	{
		fixed (UserData* ptr = &_userData)
		{
			ImGuiInputTextCallback customCallback = CustomCallback;
			ImGui.InputText("label", ref _input, 100, ~(ImGuiInputTextFlags)0, customCallback, (IntPtr)ptr);
		}

		ImGui.End();
	}
}

private unsafe int CustomCallback(ImGuiInputTextCallbackData* data)
{
	IntPtr userDataPtr = (IntPtr)data->UserData;
	if (userDataPtr != IntPtr.Zero)
	{
		UserData userData = Marshal.PtrToStructure<UserData>(userDataPtr);
		Debug.Log(userData.SomeCoolValue);
	}

	// You must to overwrite how you handle with new inputs.
	// ...

	return 1;
}

image

Custom font

Thanks
Check here for more information

  • First create a method with ImGuiIOPtr like this
public void AddJapaneseFont(ImGuiIOPtr io)
{
	// you can put on StreamingAssetsFolder and call from there like:
	//string fontPath = $"{Application.streamingAssetsPath}/NotoSansCJKjp - Medium.otf";
	string fontPath = "D:\\Users\\rofli.souza\\Desktop\\NotoSansCJKjp-Medium.otf";
	io.Fonts.AddFontFromFileTTF(fontPath, 18, null, io.Fonts.GetGlyphRangesJapanese());

	// you can create a configs and do a lot of stuffs
	//ImFontConfig fontConfig = default;
	//ImFontConfigPtr fontConfigPtr = new ImFontConfigPtr(&fontConfig);
	//fontConfigPtr.MergeMode = true;
	//io.Fonts.AddFontDefault(fontConfigPtr);
	//int[] icons = { 0xf000, 0xf3ff, 0 };
	//fixed (void* iconsPtr = icons)
	//{
	//	io.Fonts.AddFontFromFileTTF("fontawesome-webfont.ttf", 18.0f, fontConfigPtr, (System.IntPtr)iconsPtr);
	//}
}
  • Assign the object that contain these method in UImGui script image
  • Create an awesome text:
if (ImGui.Begin("ウィンドウテスト"))
{
	ImGui.Text("こんにちは!テスト");

	ImGui.End();
}

image
Yay!

You can see more samples here.

Using URP

  • Add a Render Im Gui Feature render feature to the renderer asset.
  • Assign it to the render feature field of the DearImGui component.
  • Check this issue which I describe how to make it work step by step.

Using HDRP

  • When using the High Definition Render Pipeline;
  • Add a script called Custom Pass Volume anywhere on your scene;
  • Add "DearImGuiPass"
  • Update Injection Point to before or after post processing.
  • Good to go. Any doubts see this link

Using Built in

No special sets.

Directives

  • UIMGUI_REMOVE_IMPLOT: don't load implot lib and sources.
  • UIMGUI_REMOVE_IMNODES: don't load imnodes lib and sources.
  • UIMGUI_REMOVE_IMGUIZMO: don't load imguizmo lib and sources.

Known issues

Issue: Already using System.Runtime.CompilerServices.Unsafe.dll will cause the following error: Multiple precompiled assemblies with the same name System.Runtime.CompilerServices.Unsafe.dll included or the current platform Only one assembly with the same name is allowed per platform. Resolution: add UIMGUI_REMOVE_UNSAFE_DLL`` on Project Settings > Player > Other Settings > Script define symbols > Apply > Restart Unity Editor.

Issue: ImPlot isn't work right.

Issue: Font atlas crash. There's no fix. Use callback for custom font instead

Credits

Original repo https://github.com/realgamessoftware/dear-imgui-unity
Thanks to @lacrc and @airtonmotoki for encouraging me.
https://www.conventionalcommits.org/en/v1.0.0/
https://semver.org/
https://github.com/yeyushengfan258/Lyra-Cursors
https://github.com/lob/generate-changelog

License

Dear ImGui is licensed under the MIT License, see LICENSE.txt for more information.

uimgui's People

Contributors

0xf6 avatar ousttrue avatar per-morten avatar psydack avatar simeonradivoev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uimgui's Issues

Rendering Issue - Topmost

Any suggestions for how to set the rendering/sorting layer? See these one is from the editor and one from injected at runtime.

It seem's UI object's will over-draw the DearImGui window. I've played with the Shader's renderqueue but no change. Any suggestions on how to make it top-most? (It happen's with just Dear ImGui also, same result, but where the hell to set the topmost? I've tried canvas sorting order, Camera depth, renderqueue, layer's, nothing change's it.)

BTW: I also made a fix for URP/HDRP Shader's not included in build's. It allows including into AssetBundles also. Like all those hidden/internal builtin shader's in URP/HDRP.

Capture

Capture1

Using Unity Vector instead of System Vector type

Why is this package using the System's Vector class instead of the Unity's? RG.ImGui is using Unity Vector's in ImGUI wrapper layer. We tried to replace the package to yours from RG however it's not practical to cast every single System Vector to Unity Vector. And definitely not worth to write another ImGUI wrapper layer just for Unity compatibility.

Would be nice if you convert your imgui layer to use Unity types.

How do I use URP?

Hey, I've read through the docs, but I am unable to setup URP, I just can't find where to add the rendering feature, and there is no Dear Im Gui component.. any help would be greatly appreciated (maybe post screenshots). I am using Unity 2019.

[QUESTION] Mac and Linux support

I really like this project i just wanted to know

Is there any way to make this work for linux and mac?

A second question can i use this on a commercial project?

ImPlot support?

Hi there!

Good work on this repo btw! It's so nice to have ImGui working in Unity without a hassle.

One question I have is, have you considered adding ImPlot to this package?

I actually compiled cimgui, cimplot and ImPlot.NET from scratch yesterday and added it to uimgui, but the end result was just having Unity crash when I try to use any ImPlot functions in Unity. I'm guessing the problem is that my compiler environment is not set up properly (compiler flags, etc.). Or maybe ImPlot won't work since it uses GPU acceleration?

Anyway, I was just curious if adding ImPlot is something you would consider for this repo?
Thanks

FontCustomInitializer, in general, causes issues.

When adding the package to my project for the first time, I get a NullReferenceException from UImGuiEditor.cs while adding the UImGui component. I was able to fix it by removing line 50 (EditorGUILayout.PropertyField(_fontCustomInitializer);).

ImGui and addressables (Win standalone x64)

Hi! Having trouble getting ImGui to to show in built applications. It works fine in the editor.

Subscribing to the OnImguiLayout event gives the regular callback in built application. Everything seems to be processing normally but the window/widgets won't render.

Unity version: 2021.2.16f1
Renderer: URP

Sample:

	public override void Render(UImGui.UImGui imgui) {
		UnityEngine.Debug.Log(" RENDER: " + this.GetType().Name);
		ImGui.Begin("DevParameters", ref m_Showing, ImGuiWindowFlags.MenuBar);
		{
			string search = "";
			ImGui.InputText("", ref search, 100);
			
			ImGui.Dummy(new UnityEngine.Vector2(0.0f, 10.0f));
			ImGui.Separator();
			ImGui.Dummy(new UnityEngine.Vector2(0.0f, 10.0f));

			foreach(var widget in m_Widgets) {
				widget.Render(imgui);
			}
		}
		ImGui.End();
	}

Example widget:

public class BoolInputWidget : ImGuiWidget
{
	private BoolParam m_Param = null;

	public BoolInputWidget(BoolParam param)
		: base(param.Label) 
	{
		m_Param = param;
	}

	public override bool Render(UImGui.UImGui imgui) {
		bool v = m_Param.Value;
		if(ImGui.Checkbox(Label, ref v)) {
			m_Param.SetValue(v);
			return true;
		}

		return false;
	}
}

Yields the debug log in built application but no window is rendering where as in the editor we get the correct behavior:
image

Input System not working as expected

Unity version: Unity 2021.2.19f1
Input System Version: 1.3.0
UIMGUI Version: 4.1.1

Reproduction steps:
Set platform type to 'Input System' and start the game.

KeyNotFoundException: Cannot find control '#(a)' as child of 'Keyboard:/Keyboard'
UnityEngine.InputSystem.InputControl.get_Item (System.String path) (at Library/PackageCache/[email protected]/InputSystem/Controls/InputControl.cs:417)
UImGui.Platform.InputSystemPlatform.SetupKeyboard (ImGuiNET.ImGuiIOPtr io, UnityEngine.InputSystem.Keyboard keyboard) (at Library/PackageCache/com.psydack.uimgui@1957436cf8/Source/Platform/InputSystemPlatform.cs:132)
UImGui.Platform.InputSystemPlatform.Initialize (ImGuiNET.ImGuiIOPtr io, UImGui.UIOConfig config, System.String platformName) (at Library/PackageCache/com.psydack.uimgui@1957436cf8/Source/Platform/InputSystemPlatform.cs:46)
UImGui.UImGui.SetPlatform (UImGui.Platform.IPlatform platform, ImGuiNET.ImGuiIOPtr io) (at Library/PackageCache/com.psydack.uimgui@1957436cf8/Source/UImGui.cs:294)
UImGui.UImGui.OnEnable () (at Library/PackageCache/com.psydack.uimgui@1957436cf8/Source/UImGui.cs:177)

[BUG] Unity gizmos not being drawn when custom render pass "RenderImGuiPass" is enabled... sometimes.

Hi,

I have a strange bug that sometimes in specific scenes the unity gizmos won't be drawn in play modus.
I figured out that it only happens when the Custom Pass Volume with the RenderImGuiPass is enabled and drawing a window.
As soon as I disable it, the unity gizmos reappear.
Pass enabled:
image
Pass disabled:
image

As this happens only randomly, in some scenes, it seems to be something unity changes sometimes, like the script execution order. But I have no idea how it actually happens.

I currently use Unity 2021.2.11 (but it happened in earlier versions as well)
and the latest version of this Imgui package.

[BUG] Custom font and Icon font crashes Unity Editor

Describe the bug
Unity Editor crashes on play, expected font to load.
Even if I load it the traditional way, the Icon font doesn't load in the texture.
image

To Reproduce
Steps to reproduce the behavior:

  1. Create new Font Atlas Config
  2. Assign a font to it
  3. Assign it to UImGui component
  4. Create new script to add "icon font"
  5. Add function below
  6. Add function to `Font Custom Initializer'
  7. Play the game

Version/Branch of UImGui:
Version: 4.1.0

Unity Version
2021.3.15f1

Render pipeline (Built-in)

Expected behavior
Load icon font with normal font

Screenshots
image
image

Code

// "Traditional" way -------------------------------------------------------------------------------------
public void AddFont(ImGuiIOPtr io)
{
    io.Fonts.AddFontFromFileTTF(Application.streamingAssetsPath + "\\Questrial-Regular.ttf", 14);
}
// --------------------------------------------------------------------------------------------------------

public unsafe void AddIconFont(ImGuiIOPtr io)
{
    ImFontConfig fontConfig = default;
    ImFontConfigPtr fontConfigPtr = new ImFontConfigPtr(&fontConfig);
    fontConfigPtr.MergeMode = true;
    fontConfigPtr.PixelSnapH = true;
    int[] icons = { FontIcon.IconMin, FontIcon.IconMax, 0 };
    fixed (void* iconsPtr = icons)
    {
    	io.Fonts.AddFontFromFileTTF(Application.streamingAssetsPath + "\\fa-solid-900.ttf", 13.0f, fontConfigPtr, (System.IntPtr)iconsPtr);
    }
}

Crash Report

Obtained 28 stack frames
0x00007ffb40a4252f (cimgui) igValue_Int
0x000002327e7d370a (Mono JIT Code) (wrapper managed-to-native) ImGuiNET.ImGuiNative:ImFontAtlas_Build (ImGuiNET.ImFontAtlas*)
0x000002327e7d3623 (Mono JIT Code) ImGuiNET.ImFontAtlasPtr:Build ()
0x000002327e7d13ab (Mono JIT Code) [TextureManager.cs:162] UImGui.Texture.TextureManager:BuildFontAtlas (ImGuiNET.ImGuiIOPtr,UImGui.Assets.FontAtlasConfigAsset&,UnityEngine.Events.UnityEvent`1<ImGuiNET.ImGuiIOPtr>) 
0x000002327e79f18b (Mono JIT Code) [UImGui.cs:168] UImGui.UImGui:OnEnable () 
0x000002327e945b68 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffb0fcbfeb4 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke 
0x00007ffb0fbfe764 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke 
0x00007ffb0fbfe8fc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke 
0x00007ff6359b1104 (Unity) scripting_method_invoke
0x00007ff6359909a4 (Unity) ScriptingInvocation::Invoke
0x00007ff635979ab4 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007ff635978396 (Unity) MonoBehaviour::AddToManager
0x00007ff635978af9 (Unity) MonoBehaviour::AwakeFromLoad
0x00007ff635a66b9f (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007ff635a6760c (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007ff635a67773 (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007ff63688b956 (Unity) ActivateSceneAfterReset
0x00007ff6368956a7 (Unity) EditorSceneManager::ResetOpenScenes
0x00007ff63689679a (Unity) EditorSceneManager::RestoreSceneBackups
0x00007ff63659f185 (Unity) PlayerLoopController::EnterPlayMode
0x00007ff6365aefe7 (Unity) PlayerLoopController::SetIsPlaying
0x00007ff6365b23e9 (Unity) Application::TickTimer
0x00007ff636a0619a (Unity) MainMessageLoop
0x00007ff636a0aa5b (Unity) WinMain
0x00007ff637dacade (Unity) __scrt_common_main_seh
0x00007ffba7c655a0 (KERNEL32) BaseThreadInitThunk
0x00007ffba942485b (ntdll) RtlUserThreadStart

[BUG] New package.json has invalid unity property

[Package Manager Window] Error adding package: https://github.com/psydack/uimgui.git.
Unable to add package [https://github.com/psydack/uimgui.git]:
  Manifest [REDACTED\Library\PackageCache\com.psydack.uimgui@ae7651beb4\package.json] is invalid:
    '2021.0' is not a valid `unity` property value. Expected '<year>.<version>'.

Since the last commit Unity does not let me import this in Unity 2021 LTS or 2022 LTS versions (at least)
In the interim it is possible to use the previous commit by using the package URL *
https://github.com/psydack/uimgui.git#24efc5be254c10a34850bea0fcffaecccdcb5dee
*if you remove ImGuizmo as it causes a native crash in this commit it appears

Weird artifacts on published application

Hi @psydack !

First of all thanks for making updated version of ImGUI for Unity! Thank you!

I've created simplest possible project, changes settings to use IL2CPP backend, .NET 4, and platform is set to Windows x86_64, Unity 2019.4.9f1 LTS

In editor everything looks just fine, but when I publish the app and run - this is the result - https://www.youtube.com/watch?v=L5lcuoP6Jwk.

I had to record video, otherwise it's really hard to catch that and make a screenshot.

Hopefully this is a known problem and you can help me out.

I will be really grateful for that. Thank you.

The type 'Vector4' exists in both 'System.Numerics.Vectors' and 'System.Numerics'

Hi there,

First of all, awesome plugin! Thank you for the effort for porting imgui to Unity. This is long-needed by the community.

I had the error in the title when I installed the plugin from Git. After removing the ConversionHelper class, the error is gone. Since the methods in ConversionHelper were not used anymore, I think it's safe to remove it.

Cheers!

use packageRequirement in shader files

compiling using the builtin pipeline gives errors because of the subshaders for universal and HD render pipeline.
you can add PackageRequirements that way in PassesUniversal.hlsl and DearImGui-Procedural.shader to overcome the issue

    // shader for HD render pipeline
    SubShader
    {
        Tags { "RenderType" = "Transparent" "RenderPipeline" = "HDRenderPipeline" "PreviewType" = "Plane" }
        LOD 100

        Lighting Off
        Cull Off ZWrite On ZTest Always
        Blend SrcAlpha OneMinusSrcAlpha

        Pass
        {
            PackageRequirements {
                "com.unity.render-pipelines.high-definition"
            }
            Name "DEARIMGUI HDRP"

            HLSLPROGRAM
            #pragma vertex ImGuiPassVertex
            #pragma fragment ImGuiPassFrag
            #include "./PassesHD.hlsl"
            ENDHLSL
        }
    }

Render without a window

Hello, we are currently investigating using this library as our main UI solution in our current game. We have so far been using the native Unity IMGUI solution, but are hitting a lot of bugs/issues/missing features with it that would take a very significant amount of time to fix or implement.
We have decided to use a non-retain mode for our UI to simplfy development due to not having to write as much UI glue code.

Integrating this project worked flawlessly, however I've noticed that all UI calls are always drawn within windows. While this is a nice feature we will certainly be utulizing for several aspects of the game, we would require the main UI to be drawn directly on screen, without a window wrapping around it.

How can this be achieved with this library?

Thank you for your time!

InputMultilineText

When using InputMultilineText with a maximum length of uint.MaxValue it doesn't recognize keystrokes and fails silently.

Weird Rendering Issue

image
in URP I have this issue.
I have no idea why this happening...
(my implementation is same as this one)

I'm in 2020.3.24f1 version of Unity (LTS)

When build I got error: Plugin 'System.Runtime.CompilerServices.Unsafe.dll' is used from several locations

I already have System.Runtime.CompilerServices.Unsafe in project. I added UIMGUI_REMOVE_UNSAFE_DLL in Project Settings > Player > Scripting Define Symbols and the error is gone. But when I build, the error appears again.

Plugin 'System.Runtime.CompilerServices.Unsafe.dll' is used from several locations:
 Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll would be copied to <PluginPath>/x86_64/System.Runtime.CompilerServices.Unsafe.dll
 Packages/com.psydack.uimgui/Plugins/System.Runtime.CompilerServices.Unsafe.dll would be copied to <PluginPath>/x86_64/System.Runtime.CompilerServices.Unsafe.dll
Please fix plugin settings and try again.

Do you know how to fix this?

Unity 2021.1.25f1

ImPlot has jumbled text.

Hi,
I'm trying to use ImPlot but it seems that does not work properly.
I saw that in the table of the ReadMe it only has a ~, but in the Issue where you 'introduced' implot it dies seem like it should work properly (#2 (comment)).
If I use the ShowDemoWindow.cs sample it looks like this:
image
All the other stuff works properly, only the ImPlot text is wrong. (The window on the right, is the ImPlot demo window).

Maybe I am missing something... but Im not sure.

[BUG] 5.0.0 crashes Unity 2022.3.17f1

Describe the bug
Unity crashes with a SIGSEGV error when running the example prefab with URP on 2022.3.17f1

To Reproduce
Steps to reproduce the behavior:

  1. Install the package from git link https://github.com/psydack/uimgui.git
  2. Follow the steps to set up URP rendering.
  3. Drag & drop prefab contained in the package
  4. Connect references
  5. Press play

Version/Branch of UImGui:
Version: 5.0.0

Unity Version
2022.3.17f1

Render pipeline (HDRP / URP / Built-in)
URP

Expected behavior
Able to run demo script / prefab with this unity version.


Is this too old of a Unity version or is there something I'm missing?

Log

=================================================================
	Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Managed Stacktrace:
=================================================================
	  at <unknown> <0xffffffff>
	  at ImGuizmoNET.ImGuizmoNative:ImGuizmo_BeginFrame <0x00086>
	  at ImGuizmoNET.ImGuizmo:BeginFrame <0x0001a>
	  at UImGui.UImGui:DoUpdate <0x0011a>
	  at UImGui.UImGui:Update <0x0003a>
	  at System.Object:runtime_invoke_void__this__ <0x00087>
=================================================================
Received signal SIGSEGV
Obtained 2 stack frames
RtlLookupFunctionEntry returned NULL function. Aborting stack walk.
<Missing stacktrace information>

EDIT: to circumvent you can add the defines:

UIMGUI_REMOVE_IMPLOT
UIMGUI_REMOVE_IMNODES
UIMGUI_REMOVE_IMGUIZMO

Setting FXAA on a camera in URP completely stops rendering of the UI [BUG]

Describe the bug
While trying to set up UImGUI on our project I couldn't get the UI to render at all. It turned out that the camera had the AA option set to FXAA.
In step 7 of your instruction #14 (comment), you mention that the shaders do not work well with FXAA. Now as it turns out, they don't work at all.

Packages like this one, as great as they are, should not dictate the camera settings. It would be great if you could fix that, and I hope that this ticket will help others to fix this problem 😅

To Reproduce

  1. Create an empty project with Unity 2023.2.8f1 using URP
  2. Import the uimgui package
  3. Set up the package using this instruction: #14 (comment)
  4. Change Anti-Aliasing setting to FXAA
  5. See error

Version/Branch of UImGui:
Version: 5.0.0

Unity Version
2023.2.8f1

Render pipeline (HDRP / URP / Built-in)
URP

Expected behavior
The UI should render normally

Screenshots
image
image
image

[BUG] Invisible when camera environment background type is set to "Color"

Describe the bug
The ImGui rendering disappears completley when you set the camera's environment background type to "Color".

To Reproduce
Steps to reproduce the behavior:

  1. Set up a new project according to the README file of this repo
  2. Add a camera
  3. Set the camera's Environment > Background Type to "Color". The color itself does not matter
  4. The ImGui will disappear.

Version/Branch of UImGui:
Version: 4.0.1

Unity Version
2021.2.11f1

Render pipeline (HDRP / URP / Built-in)
HDRP

Expected behavior
The UI should be visible.

Unable to load fonts via FontAtlas

Hi there.

I'm trying to add a font using the font atlas, but it doesn't work.
To do this I'm following these steps:

  • Download a monospace font from Google Fonts to some data folder in Assets.
  • In Unity, open font generator (Window->TextMeshPro->FontAssetCreator).
  • In the Font Asset Creator, I set some parameters and generate the font:
    image
  • Click on "Save as..." and store the asset in my StreamingAssets folder.
  • Add the font asset to the FontAtlasConfigAsset:
    image
  • Make sure the atlas is set in the UImGui script.
    image
  • Run the application, no ImGui menus or windows appear, and get this error message:
    image

Could anyone help me please?

[BUG?] Input platforms use too new C# features for Unity 2020.3

Describe the bug
With the package version reversion, this package is still downloadable (and otherwise fully functional) in Unity 2020
I'm using this version in a production application where Unity upgrades have not been preformed yet due to the nature of Unity upgrades and the worry of introducing bugs.

Unity Version
2020.3.21f1

Additional context
Replacing the new() with their full equivalents, and the switch() with the old style switch(key) allows the compilation and function of UImGui

[QUESTION] How does ImGuizmo work with Unity?

I've tried rendering a simple box gizmo. And what ever I try doesn't seem to work. Doesn't help that there is barely any documentation anywhere (.NET and C++ Side)

I Would of thought this is all I had to do.

ImGuizmo.SetOrthographic( false );
var io = ImGui.GetIO();
ImGuizmo.SetRect( 0, 0, io.DisplaySize.x, io.DisplaySize.y );

var camera = Engine.Camera;
var matrix = entity.transform.localToWorldMatrix[0];
var view = camera.worldToCameraMatrix[0];
var projection = camera.projectionMatrix[0];

ImGuizmo.Manipulate( ref view, ref projection, OPERATION.TRANSLATE, MODE.WORLD, ref matrix );

But nothing shows in the viewport.

SetCamera-Method

Hey i really like you project, the only thing is, that currently it is not possible to set the used camera from the outside, and in OnEnable there is already a Fail-Check. It would be nice if we could set the camera after instantiating UImGui (UImGui.cs) as a prefab and then Reload.

Is it possible to implement a SetCamera(Camera camera) - Method?

Best Regards

Chris

[BUG] Having issues with building a Unity project

Describe the bug
Can't build a project that has this library, results in a load of errors. Pretty sure it has something to do with Unity not knowing what the external dependencies are when compiling.

To Reproduce
Steps to reproduce the behavior:

  1. Build the project
  2. Results in console

Version/Branch of UImGui:
Version: "4.1.1"

Unity Version
2021.2.6f1 & 2022.1b

Render pipeline (HDRP / URP / Built-in)
Built In

Expected behavior
Not throw a million errors when compiling

Screenshots
image

Custom drawing doesn't work

I tried recreating what imgui_demo.cpp shows

ImGui.Begin(WindowName, ref IsWindowOpen, ImGuiWindowFlags.None);

ImDrawListPtr drawList = ImGui.GetWindowDrawList();

drawList.AddRect(new Vector2(10,10), new Vector2(20, 20), 1973790, 0.0f, ImDrawFlags.None, 2); 

ImGui.End();

but no luck...
I'm not sure if I'm doing something wrong or if it's a bug.

Unity 2020.3.25.f1
ImGUI 1.84 WIP
uimgui 4.1.0

[QUESTION] I figured out how to draw Gizmo from ImGuizmo, but they distorted.

Well, as the title says, I figured out how to draw it all, but for some reason it doesn't display correctly. I'm not very good at matrices and I have no idea how to fix it at all.

I`m using Unity 2021.1.17f1 with Built-in render pipeline.
Package version 4.1.1 (Last at the moment.)

https://youtu.be/yEWYUFGb97w

private void OnLayout(UImGui.UImGui obj)
{
ImGuizmo.BeginFrame();
ImGuizmo.SetRect(0, 0, Screen.height, Screen.width);

Matrix4x4 matrix = _objectInScene.transform.localToWorldMatrix;
Matrix4x4 view = _currentCamera.worldToCameraMatrix;
Matrix4x4 projection = _currentCamera.projectionMatrix;

ImGuizmo.Manipulate(ref view.m00, ref projection.m00, OPERATION.TRANSLATE, MODE.WORLD, ref matrix.m00);
ImGuizmo.DrawGrid(ref view.m00, ref projection.m00, ref matrix.m00, 50f);

}

[QUESTION] WebGL support?

Running in the browser produces following error

DllNotFoundException: Unable to load DLL 'cimgui'. Tried the load the following dynamic libraries:

Also, there is an error after build

Shader error in 'DearImGui/Procedural': SV_VertexID semantic is not supported on GLES 2.0 at line 58 (on gles)

Compiling Subshader: 1, Pass: DEARIMGUI PROCEDURAL BUILTIN, Vertex program with <no keywords>
...

[BUG] Custom Font Crashing Unity

Describe the bug
When using a font atlas configuration with a custom font file, it crashed unity upon starting the game.
Even when using a callback as described in the readme, the same crash occurs randomly after multiple starts of the game.

To Reproduce
Steps to reproduce the behavior uning config:

  1. Create a new Font Atrals Config
  2. Assign a font to it
  3. Assign it to U Im GUI component
  4. Play the editor/game
    Steps to reproduce the behavior uning config:
  5. Used described method in readme, create method for custom font loading
  6. Start the game and stop it multiple times

Version/Branch of UImGui:
Version: 4.1.0

Unity Version
2021.3.6f1

Render pipeline (URP)

Expected behavior
Editor should not crasah

Screenshots
image

** Code **

public class FontLoadingComponent : MonoBehaviour
    {
        public unsafe void LoadFontAwesome(ImGuiIOPtr io)
        {
            var fontPath = $"{Application.persistentDataPath}/Font Awesome 6 Free-Regular-400.otf";
            io.Fonts.AddFontFromFileTTF(fontPath, 18, null, io.Fonts.GetGlyphRangesDefault());
        }
    }

Crash Report

Obtained 31 stack frames
0x00007ffe4955252f (cimgui) igValue_Int
0x000002561a437c57 (Mono JIT Code) (wrapper managed-to-native) ImGuiNET.ImGuiNative:ImFontAtlas_Build (ImGuiNET.ImFontAtlas*)
0x000002561a437a7b (Mono JIT Code) ImGuiNET.ImFontAtlasPtr:Build ()
0x000002561a430f5b (Mono JIT Code) [TextureManager.cs:161] UImGui.Texture.TextureManager:BuildFontAtlas (ImGuiNET.ImGuiIOPtr,UImGui.Assets.FontAtlasConfigAsset&,UnityEngine.Events.UnityEvent`1<ImGuiNET.ImGuiIOPtr>) 
0x000002561a42517b (Mono JIT Code) [UImGui.cs:166] UImGui.UImGui:OnEnable () 
0x00000256cfb14188 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffe3eebe4b4 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke 
0x00007ffe3edfe764 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke 
0x00007ffe3edfe8fc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke 
0x00007ff7dcefdac4 (Unity) scripting_method_invoke
0x00007ff7dcef8644 (Unity) ScriptingInvocation::Invoke
0x00007ff7dcec62b4 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007ff7dcec4b02 (Unity) MonoBehaviour::AddToManager
0x00007ff7dcec5341 (Unity) MonoBehaviour::AwakeFromLoad
0x00007ff7dcfb374f (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007ff7dcfb41bc (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007ff7dcfb4323 (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007ff7dcbffe58 (Unity) LoadSceneOperation::CompleteAwakeSequence
0x00007ff7dcc008d2 (Unity) LoadSceneOperation::CompletePreloadManagerLoadSceneEditor
0x00007ff7dcc0147b (Unity) LoadSceneOperation::IntegrateMainThread
0x00007ff7dcc05071 (Unity) PreloadManager::UpdatePreloadingSingleStep
0x00007ff7dcc0564f (Unity) PreloadManager::WaitForAllAsyncOperationsToComplete
0x00007ff7ddde4b36 (Unity) EditorSceneManager::RestoreSceneBackups
0x00007ff7ddaf5515 (Unity) PlayerLoopController::EnterPlayMode
0x00007ff7ddb04a67 (Unity) PlayerLoopController::SetIsPlaying
0x00007ff7ddb07e6d (Unity) Application::TickTimer
0x00007ff7ddf537aa (Unity) MainMessageLoop
0x00007ff7ddf5805b (Unity) WinMain
0x00007ff7df2db42e (Unity) __scrt_common_main_seh
0x00007ffedfd07034 (KERNEL32) BaseThreadInitThunk
0x00007ffee0422651 (ntdll) RtlUserThreadStart

Repo status?

  • Last commit in master branch on Jan 31, 2022
  • for HDRP not compatible (for some reason it is written that it is compatible - rather it just runs with a bunch of artifacts)
  • Main native library is not updated in this repo

Based on this, the question is - what is the status of the project?

HDRP: UI often shows up in scene view instead of game view and gizmos don't show where ImGui is drawn.

I don't know if this happens in other pipelines as well - but in HDRP the UI often likes to show up in the scene view and not appear in the game view at all - unless fullscreen.

I'm posting this issue so other people could perhaps look at it - but right now I've remedied this by not using the custom pass volume the guide describes - but by using a component that subscribes to some events the scriptable render pipeline exposes. This seems to work well so far. I will attach the script I use for this in a gist.

https://gist.github.com/stepperman/45cb274e6a224455aaa421eb7a61dbb7

It's pretty untested - but seems to work well so far. It will still for some reason go to the scene view when the game view is maximised and then minimised but I feel this is barely a non-issue. The only gripe I have right now is that the UI renders over the Unity canvas, but for some reason Unity don't expose proper injection points for that unfortunately.

iOS support is gone

Hi pysdack, as you know we are actively using your fork for imgui. As I see dylib for mac and ios builds are removed from the plugins folder.

Can you provide the links of the used versions of ImGUI.NET, cimgui and imgui of sources so we can build it ourselves?

Also as a side note, if you wish to build them yourself and add to this repo, Apple doesn't allow dylib in the AppStore (not sure about the details we tried it with RG and got rejected from appstore). So a separate static library build is required for cimgui and some minor modifications needed to be done on the source so it points to the static library instead of the dynamic library.

If you wish to give support for iOS, we can share our know-how back and forth.

[FEATURE] BeginTabItem missing possibility to set Flags without open/close ref bool.

Hi,
I just had the problem that the BeginTabItem cannot be called easily with flags enabled, if you don't want the open/close tab feature.
In the C version of ImGui this can be done by passing a nullpointer as the p_open param. But as C# does not allow this in normal code (as far as I know?), there would need to be an additional overload without the "ref bool p_open" param.

For me I now solved this by copying the generated implementation of the imguiNET and changing it by just passing null.

public static bool BeginTabItem(string label, ImGuiTabItemFlags flags)
{
    byte* native_label;
    int label_byteCount = 0;
    if (label != null)
    {
        label_byteCount = Encoding.UTF8.GetByteCount(label);
        if (label_byteCount > 2048)
        {
            native_label = (byte*)Marshal.AllocHGlobal(label_byteCount + 1);
        }
        else
        {
            byte* native_label_stackBytes = stackalloc byte[label_byteCount + 1];
            native_label = native_label_stackBytes;
        }
        int native_label_offset = GetUtf8(label, native_label, label_byteCount);
        native_label[native_label_offset] = 0;
    }
    else { native_label = null; }
    byte ret = ImGuiNative.igBeginTabItem(native_label, null, flags);
    if (label_byteCount > 2048)
    {
        Marshal.FreeHGlobal((IntPtr)native_label);
    }
    return ret != 0;
}

private static int GetUtf8(string s, byte* utf8Bytes, int utf8ByteCount)
{
    fixed (char* utf16Ptr = s)
    {
        return Encoding.UTF8.GetBytes(utf16Ptr, s.Length, utf8Bytes, utf8ByteCount);
    }
}

Missing Profiler.EndSample errors using HDRP + having Profiler window open.

Hello,

as soon as I open the Profiler window I get errors complaining that the BeginSample and EndSample count don't match.
This happens only if the RenderImGuiPass is added to the CustomPassVolume.
Maybe I'm doing something wrong, but I don't think so.

Missing Profiler.EndSample (BeginSample and EndSample count must match): Custom Pass
Previous 5 samples:
RenderLoop.CleanupNodeQueue
RenderTexture.SetActive
DearImGui.ExecuteDrawCommands
UImGui
RenderLoop.CleanupNodeQueue
In the scope:
Custom Pass
HDRenderPipeline::Render Main Camera
Inl_Custom Pass
Inl_HDRenderPipeline::Render Main Camera
Inl_HDRenderPipelineAllRenderRequest

image

Greetings,
TJ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.