- Home /
"Uncheck all" in Gizmos menu in Scene view?
How do I uncheck all the checkboxes under the column "gizmo" in the Gizmos menu, in the Scene view of the Unity Editor, without clicking each one individually? Our project has hundreds of these, and each time I need to help a new artist (or someone running a new beta install) with them, we have to mouse click each individually.
Answer by Immanuel-Scholz · Nov 20, 2014 at 11:42 PM
There is no official way (none I am aware of), but depending on your willingness to dig into deep private reflection stuff of UnityEditor.dll, you could write some editor code to do this.
Basically from what I see from the decompile, class AnnotationWindow controls the UI. It uses AnnotationUtility.GetAnnotations to obtain information about what classes have gizmos available and uses AnnotationUtility.SetGizmoEnabled to enable/disable the gizmo (SetIconEnabled to enable/disable the icon).
Let me try... yea, this one should work.. here you go: Menu option "Window / Disable All Gizmos" to turn off everything in a blink.
using UnityEditor;
using System;
using System.Reflection;
public class DisableAllGizmos
{
[MenuItem("Window/Disable All Gizmos")]
static void DisableAllGizmosMenu()
{
var Annotation = Type.GetType("UnityEditor.Annotation, UnityEditor");
var ClassId = Annotation.GetField("classID");
var ScriptClass = Annotation.GetField("scriptClass");
Type AnnotationUtility = Type.GetType("UnityEditor.AnnotationUtility, UnityEditor");
var GetAnnotations = AnnotationUtility.GetMethod("GetAnnotations", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
var SetGizmoEnabled = AnnotationUtility.GetMethod("SetGizmoEnabled", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
var SetIconEnabled = AnnotationUtility.GetMethod("SetIconEnabled", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
Array annotations = (Array)GetAnnotations.Invoke(null, null);
foreach (var a in annotations)
{
int classId = (int)ClassId.GetValue(a);
string scriptClass = (string)ScriptClass.GetValue(a);
SetGizmoEnabled.Invoke(null, new object[] { classId, scriptClass, 0 });
SetIconEnabled.Invoke(null, new object[] { classId, scriptClass, 0 });
}
}
}
@pvtgreg: Well, in line 25 you would pass "1" ins$$anonymous$$d of "0". Same in line 26 for SetIconEnabled.
Created a request to make this easier: https://feedback.unity3d.com/suggestions/please-add-ability-to-disable-slash-hide-all-gizmos
Hello, Is there an update of this wonderfull script for Unity 2019 ? It still working in 2018 but not in 2019. From tracing the code it seems the Field name changed, "scriptClass" for example return "null". Cheers,
To make it work again in Unity 2019.x In row 25 change: SetGizmoEnabled.Invoke(null, new object[] { classId, scriptClass, 0 }); to: SetGizmoEnabled.Invoke(null, new object[] { classId, scriptClass, 0, false });
Thanks a lot, it fixed it.
How did you manage to find this, my knowledge in C# reflexion system was too low to find you by myself.
As I used it for also enabling all gizmo and restore/save state, here's a precision It's the '0' parameter that disable not the 'false'. SetGizmoEnabled.Invoke(null, new object[] { classId, scriptClass, _enabled ? 1 : 0,false });
How would I modify this to preserve the state of the previous checked/unchecked gizmos? Currently this script will all or nothing it. If I had 10 Gizmos manually disabled, they'll all be set back to enabled after I reverse the script (by putting 1 instead of 0)... so need to keep a list of all gizmo's state first and then choose 1 or 0 depending on that list..
Need a "GetGizmoEnabled.Invoke"
Any ideas?
Answer by MSGVentures · May 11, 2017 at 11:53 AM
One quick and easy way to hide all the gizmos is to open the Gizmos menu in the Scene viewer and make sure 3D Icons is checked. Then slide the size slider all the way to the left so they shrink down to nothing.
Created a request to make this easier: https://feedback.unity3d.com/suggestions/please-add-ability-to-disable-slash-hide-all-gizmos
Answer by Grizmu · Jul 23, 2019 at 02:55 PM
If you want to do something about it, and don't feel like figuring all the reflection methods out, or have no time to do so, I've released an asset called VoltGizmos, which allows you to show/hide all gizmos/icons with one click, as well as create your own snapshots.
It'll prove useful to you especially if you have lots of custom objects, which use gizmos, and the scene view feels more like a slideshow than a fluid experience, but you don't want to toggle gizmos manually all the time, as it's tiresome.
Here you can check the workflow comparison: Video
Your answer
Follow this Question
Related Questions
Labeling objects in the scene editor view 2 Answers
Unity UI Disable Annoying Yellow Arrow 1 Answer
Gizmos icons 0 Answers