- Home /
Question by
cosmogonies.net · Apr 21, 2015 at 05:54 AM ·
hierarchyfindinactivedisabled
Find all GameObjects like Hierarchy view, including inactive roots.
I am making a custom Hierarchy view in the Unity Editor.
I'm facing an issue with inactive GameObjects that have no parents, no tags, no layers. I can't find anything to list them : GameObject.Find ignore inactive objects.
Object.FindObectsOfType ignore inactive objects.
Resources.FindObjectsOfTypeAll find them but with a lot of internal stuff (the Camera of the Editor also have no parent for exemple).
Is there anyway to do this ?
Comment
found something interesting here ... but that's more a workaround.
Anyway you can do :
public static IEnumerable<GameObject> GetSceneRoots()
{
HierarchyProperty currentHierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects);
int[] expanded = new int[0];
while (currentHierarchyProperty.Next(expanded))
{
yield return currentHierarchyProperty.pptrValue as GameObject;
}
}