Skip to content

[BUG] ImGui window shows up even when _isOpen is false #71

@ArnaudDroxler

Description

@ArnaudDroxler

Describe the bug
Hello,

I’m experiencing an issue with the integration of ImGui in my Unity project. I have a script using UImGui, and even when I set the p_open variable to false, the window still appears. And when i click the top right cross for closing the windows, the windows stay open (the windows blink ).

To Reproduce
Steps to reproduce the behavior:

  1. Create a new scene
  2. Add SampleDemoWindow
  3. Attach linked script to SampleDemoWindow
  4. Setup UImGui script (Render feature, camera )
  5. Play
  6. The window should be close but it appears

Version/Branch of UImGui:
Version: 5.0.0

Unity Version
2022.3.19f1

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

Expected behavior
The window should not be displayed when p_open is set to false.

Standalone, minimal, complete and verifiable example:

using UnityEngine;
using ImGuiNET;
public class TestUImGUI : MonoBehaviour
{
	[SerializeField]
	private UImGui.UImGui _uimGuiInstance;
    private bool _isOpen = false;

	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;
	}

    private void OnLayout(UImGui.UImGui obj)
    {

        _isOpen = false;
        if (!ImGui.Begin("Test Window", ref _isOpen))
        {
            ImGui.End();
            return;
        }

        ImGui.Text("Hello, World!");
        ImGui.End();
    }

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions