dragon1672

UnityKiller

May 21st, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. public class Killer : MonoBehaviour {
  2.  
  3.     // Use this for initialization
  4.     void Start ()
  5.     {
  6.         StartCoroutine(DestoryRoots());
  7.     }
  8.    
  9.     public static IEnumerable<GameObject> SceneRoots()
  10.     {
  11.         var prop = new HierarchyProperty(HierarchyType.GameObjects);
  12.         var expanded = new int[0];
  13.         while (prop.Next(expanded))
  14.         {
  15.             yield return prop.pptrValue as GameObject;
  16.         }
  17.     }
  18.  
  19.     static IEnumerator DestoryRoots() // this will kill my parent
  20.     {
  21.         foreach (var sceneRoot in SceneRoots())
  22.         {
  23.             Destroy(sceneRoot);
  24.             yield return null;
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment