Quantcast
Channel: Answers for "GameObject.Find() work on inactive objects"
Viewing all articles
Browse latest Browse all 45

Answer by bdawson

$
0
0
This is kind of gross, but it works well: public static List GetAllObjectsInScene(bool bOnlyRoot) { GameObject[] pAllObjects = (GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject)); List pReturn = new List(); foreach (GameObject pObject in pAllObjects) { if (bOnlyRoot) { if (pObject.transform.parent != null) { continue; } } if (pObject.hideFlags == HideFlags.NotEditable || pObject.hideFlags == HideFlags.HideAndDontSave) { continue; } if (Application.isEditor) { string sAssetPath = AssetDatabase.GetAssetPath(pObject.transform.root.gameObject); if (!string.IsNullOrEmpty(sAssetPath)) { continue; } } pReturn.Add(pObject); } return pReturn; }

Viewing all articles
Browse latest Browse all 45

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>