Find All GameObjects currently that are in the Hierarchy Window view
I'm writing a custom inspector for the Hierarchy but the script gets bogged down because EditorApplication.HierarchyWindowItemOnGUI goes through and draws every gameObject whether or not it is currently viewed on screen. I'd like to check and see if they are actually visible and in the Window's view in the hierarchy.
It's more a convenience thing than a needed thing.
Answer by Diet-Chugg · Feb 01, 2017 at 10:00 PM
Figured it out.
EditorWindow _wnd = EditorWindow.GetWindow(WndType, false, "Hierarchy", false);
static void HierarchyWindowItemOnGUI(int instanceID, Rect selectionRect)
{
UnityEngine.Object obj = EditorUtility.InstanceIDToObject(instanceID);
if (obj == null || obj.hideFlags.Has(HideFlags.HideInInspector) || obj.hideFlags.Has(HideFlags.HideInInspector))
{
return;
}
if (HierarchyWindow.position.height < selectionRect.y &&
0 > selectionRect.y)
{
return;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612110116im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
GUI.Window. Wanting to allow clickthrough 0 Answers
How to send event for window on Full screen 0 Answers
HideFlags.HideInHierarchy not updating hierarchy in Edit-mode 3 Answers
Creating an Inspector view that only changes on scene hierarchy selection or asset selection 1 Answer
OnPreviewGUI for Canvas and UI Elements 0 Answers