popcron / gizmos

Used for drawing runtime gizmos in builds and editor (Unity3D)
MIT License
549 stars 43 forks source link

[2018.4.23] Not working in Play Mode #21

Open jbltx opened 4 years ago

jbltx commented 4 years ago

Hello, Apparently, in my project, the rendering of gizmos works well only in the Editor when the Play Mode is not enabled. I can see the gizmos in SceneView and Game View.

I am using Unity 2018.4.23f1 and the legacy render pipeline (no Render Pipeline Asset). When debugging, I can see I go through all the drawing process, so I am not sure what is different in Play Mode. The Gizmos Draw methods are called into my OnRenderObject() method (ExecuteAlways attribute is used to see the result in the editor).

I thought it could come from the onPostRender event, but even without PostProcess activated in the scene, I am not able to see it.

Any ideas ? Thank you.

EDIT :

After more investigation, it seems the GizmosInstance.queuIndex is equal to 1 when it arrives at OnRendered(Camera cam). So only the dummy Gizmos is processed. But in the queue, there are all the submitted Gizmos through OnRenderObject()...

I will let you know if I find something.

jbltx commented 4 years ago

It seems to be a synchronization problem, what I can see is, all my scripts submit draw in the queue, then when the dummy gizmos (from GizmosInstance.Update() ) is submitted, it seems to be another frame, so the queueIndex is reset, and only the dummy is actually rendered. For now my workaround is to reset the queueIndex only at the end of OnRederered(Camera camera). Now it's working fine for PlayMode, but of course this won't work in SceneView/GameView in editing Mode. For now the most important is the PlayMode.

image

popcron commented 4 years ago

Hm, the fix would likely be to do add a #if UNITY_EDITOR for this exact case since it can only ever happen in the editor. I did have issues like yours in the past, and I thought I fixed it but I guess not lol. If I have time I will fix it, otherwise a PR would be great for this since I'm pretty busy.

CycloneRing commented 2 years ago

Any news @popcron ? same issue