[Solved] Strange ImGui issue possibly related to ImGui.PushID()

  • MonoGame DesktopGL 3.8.0.1641
  • .NET 6.0
  • ImGui NET 1.87.3 using the example implementation*

I have an “inventory” ImGui window that contains a grid of Buttons and ImageButtons. The grid is drawn with a foreach from a simple 1D array.

When a button is clicked, its respective index is saved in int _selectedInventorySlot and when _selectedInventorySlot matches the index of a button, that button is drawn with a red border.

This works just fine. But, after clicking a button 4 times, all the text in every ImGui windows completely disappears. Everything else is still drawn correctly and all the buttons still work but there is no text…

I have a suspicion it might be casued by an incorrect use of PushID and PopID because I have no idea if I’m actually using them correctly…

Screenshots

Source

Any ideas? I’m very confused.

* github. com/mellinoe/ImGui.NET/blob/master/src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs (sorry about the mangled link, I can only post 2 links in one post)

I was changing the _selectedInventorySlot variable on a button click which caused the condition around PopStyleColor to fire at the wrong time which was presumably messign with everything else.