Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. private static void FindInGo(GameObject g)
  2.     {
  3.         var components = g.GetComponents<Component>();
  4.  
  5.         var r = 0;
  6.  
  7.         for (var i = 0; i < components.Length; i++)
  8.         {
  9.             if (components[i] != null) continue;
  10.             var s = g.name;
  11.             var t = g.transform;
  12.             while (t.parent != null)
  13.             {
  14.                 s = t.parent.name +"/"+s;
  15.                 t = t.parent;
  16.             }
  17.  
  18.             var serializedObject = new SerializedObject(g);
  19.  
  20.             var prop = serializedObject.FindProperty("m_Component");
  21.  
  22.             prop.DeleteArrayElementAtIndex(i-r);
  23.             r++;
  24.  
  25.             serializedObject.ApplyModifiedProperties();
  26.         }
  27.  
  28.         foreach (Transform childT in g.transform)
  29.         {
  30.             FindInGo(childT.gameObject);
  31.         }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement