psydack / uimgui

UImGui (Unity ImGui) is an UPM package for the immediate mode GUI library using ImGui.NET. This project is based on RG.ImGui project.
MIT License
351 stars 56 forks source link

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

Closed gwenvis closed 1 year ago

gwenvis commented 2 years ago

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.

psydack commented 2 years ago

Hello there.

Could you share which version this is happening/reproduce? Could you share some image / video of this happening ?

Thank you very much for sharing the snippet and using UImGui.

iUltimateLP commented 2 years ago

Wanted to comment on this, as we're experiencing the same issue. The Gist provided by @stepperman works just fine, although we noticed that it does screw with the alpha channel, making transparent windows way more transparent as they were previously.

Edit: we fixed that by switching the alpha mode to a seperate blend, add this to every pass in Resources/Shaders/DearImGui-Mesh.shader:

Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
futurecreep-dev commented 1 year ago

(UImGui 4.1.1, HDRP 15.0.6, 2023.1.6f1, Windows DX11, Custom Buffer Format R8G8B8A8 - did not test others) The custom pass method makes UImGui display in Game view only if Gizmos are enabled; It's always visible in Scene view (while playing). Even so, I found these other issues:

Using the gist code instead (custom pass removed) it works and looks as expected, in builds included. However, I modified the handler so it only runs for the main camera, otherwise UImGui flickers when on demand reflection probes get rendered (I think). It still has occasional 1-frame flickers in Editor but I don't mind for now.