Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<GameObject> GetAllObjectsOfTypeInScene<T>()
- {
- List<GameObject> objectsInScene = new List<GameObject>();
- foreach (GameObject go in Resources.FindObjectsOfTypeAll(typeof(GameObject))
- as GameObject[])
- {
- if (go.hideFlags == HideFlags.NotEditable ||
- go.hideFlags == HideFlags.HideAndDontSave)
- continue;
- if (go.GetComponent<T>() != null)
- objectsInScene.Add(go);
- }
- return objectsInScene;
- }
Advertisement
Add Comment
Please, Sign In to add comment