"Uncheck all" in Gizmos menu in Scene view?
Asked Answered
C

4

0

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.

Consalve answered 30/1 at 8:18 Comment(0)
P
0

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 });
        }
    }
}
Preside answered 30/1 at 8:18 Comment(5)

what would i change so that i can turn on all gizmos?

Anapest

@pvtgreg: Well, in line 25 you would pass "1" instead of "0". Same in line 26 for SetIconEnabled.

Uxorial

Created a request to make this easier: https://feedback.unity3d.com/suggestions/please-add-ability-to-disable-slash-hide-all-gizmos

Rhyolite

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,

Hangman

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?

Jerkwater
K
0

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.

Kipton answered 6/6, 2023 at 2:32 Comment(1)

Created a request to make this easier: https://feedback.unity3d.com/suggestions/please-add-ability-to-disable-slash-hide-all-gizmos

Rhyolite
G
0

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:

Gormley answered 30/1 at 8:16 Comment(0)
T
0

You can now use Icon[("icon_path")].in 2021.2:

#if UNITY_2021_2_OR_NEWER
    [Icon(k_IconPath)]
#endif
    public sealed class PhysicsBodyAuthoring : MonoBehaviour
    {
        const string k_IconPath = "Packages/com.unity.physics/Unity.Physics.Editor/Editor Default Resources/Icons/[email protected]";

        PhysicsBodyAuthoring() {}
    }
Tamishatamma answered 30/1 at 1:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.