Last active
September 30, 2024 13:30
-
-
Save FlaShG/38d860c836d9e09d606def9e6069024a to your computer and use it in GitHub Desktop.
Shows all GameObjects in the scene with hideFlags, so you can debug them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
public static class HideFlagsUtility | |
{ | |
[MenuItem("Help/Hide Flags/Show All Objects")] | |
private static void ShowAll() | |
{ | |
var allGameObjects = Object.FindObjectsOfType<GameObject>(true); | |
foreach (var go in allGameObjects) | |
{ | |
switch (go.hideFlags) | |
{ | |
case HideFlags.HideAndDontSave: | |
go.hideFlags = HideFlags.DontSave; | |
break; | |
case HideFlags.HideInHierarchy: | |
case HideFlags.HideInInspector: | |
go.hideFlags = HideFlags.None; | |
break; | |
} | |
} | |
} | |
} |
Thanks for sharing. I would like to make some minor additions;
Sometimes objects are staying disabled, that's why i used var allGameObjects = Object.FindObjectsOfType<GameObject>(true);
Also i needed to search for null components: int nullComponents = go.GetComponents(typeof(Component)).ToList().FindAll((x)=>x is null).Count;
of course, to use ToList() and FindAll() , you also need to add using System.Linq;
i hope these also can help for someone if needed.
This is excellent, thank you! I had a couple of hidden prefab objects in my scene that had broken references, and since they were hidden, I could never see them in the hierarchy. This worked perfectly to show them and let me delete them. Thank you! :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been working around editor scripts and I've come across with object hiding at some point. However they've managed to stay hidden out of my control. This script helped me a lot, so thank you!