performance issue with gizmo enabled

Hi,

I have an issue in the editor.
In my project, I have a lot of scripts (like 5 base class with ten / thousand of subclasses for each)… To identify them easily, I added icons to each “family”.

In the scene view, performance are somewhat ok. But when I start play mode and go back to scene view, I am under 10 or 5 fps which is really annoying.

I noticed that if I disable gizmos in scene view this way :
5656396--588475--Screenshot_2.jpg
Performances are back to normal.

So I have several questions :

-Almost none of them have OnDrawGizmo so why does it propose to me to enable or disable gizmo ?

-Why is there a difference between play mode On and Off (even if the two windows aren’t displayed simultaneously)

-Is the large amount of scripts responsible of my performance hit ?

-If so, is there a way to prevent my script with custom icons to be added to the gizmos window ?

-In last resort I can’t find a way to programatically toggle the button. I found a way online by using reflection and Editor function :

            Assembly asm = Assembly.GetAssembly(typeof(Editor));
            Type type = asm.GetType("UnityEditor.AnnotationUtility");
          
            MethodInfo getAnnotations = type.GetMethod("GetAnnotations", BindingFlags.Static | BindingFlags.NonPublic);
            MethodInfo setGizmoEnabled = type.GetMethod("SetGizmoEnabled", BindingFlags.Static | BindingFlags.NonPublic);
            MethodInfo setIconEnabled = type.GetMethod("SetIconEnabled", BindingFlags.Static | BindingFlags.NonPublic);

It does indeed toggle gizmos and icons state but does not fix my performance issue. It is only when I toggle the gizmo button manually with the mouse that there is a change in performance…

Can you help me with that ?

The gizmo toggle also toggles the drawing of those icons, in addition to OnDrawGizmos. Gizmos is also horrendously poorly optimized, they have always been.

The load of both drawing those icons and playing your game is probably what’s causing the slowdown. When you’re not looking at the scene window, the gizmos are not drawn.

1 Like

Yes but I have the same performance issue when I disable all the gizmo / icon of all components listed in Gizmos. In that case, it doesn’t draw anything because everything is disabled. Yet, same performance issue.

And how to apply the same effect as disabling Gizmo programatically ?

Up

Same issue with us, switching Gizmo’s on at all causing severe FPS drop. Editor profiling shows a long time spent repainting the views. We have locked all of our Debug Draw lines behind bool but still the lag persists if Gizmos is on makes it very difficult to use Debug Draw lines effectively.