예제 #1
0
 public static void CreateComponentList(GameObject go)
 {
     Inspector.RemoveAllFromGUI(Inspector.componentChoice);
     Inspector.InspectComponent(null);
     Inspector.componentChoice = new List <CustomGUI>();
     Component[] array = go.GetComponents <Component>();
     for (int i = 0; i < array.Length; i++)
     {
         Component          component = array[i];
         Tuple <Rect, Rect> tuple     = Inspector.SplitRect(new Rect(0.7f, 0.4f + 0.02f * (float)i, 0.1f, 0.02f), 0.1f);
         Button             destroyB  = new Button(tuple.Item1, "X", JMTKGUI.GUIElement.Button, delegate()
         {
             if (component.GetType() == typeof(Transform))
             {
                 UnityEngine.Object.Destroy(((Transform)component).gameObject);
                 Inspector.CreateComponentList(go);
                 return;
             }
             UnityEngine.Object.Destroy(component);
             Inspector.CreateComponentList(go);
         });
         Button b = new Button(tuple.Item2, component.GetType().Name, JMTKGUI.GUIElement.Button, delegate()
         {
             Inspector.InspectComponent(component);
         });
         Inspector.componentChoice.Add(b);
         Inspector.componentChoice.Add(destroyB);
     }
     Inspector.AddAllToGUI(Inspector.componentChoice);
 }
예제 #2
0
 public static void CreateList(GameObject parentObject = null)
 {
     try
     {
         int layer = 0;
         if (parentObject != null)
         {
             layer = Inspector.CountParents(parentObject);
             try
             {
                 Inspector.CreateComponentList(parentObject);
             }
             catch (Exception)
             {
                 Debug.Log("Concurrent modification while listing thing?");
             }
         }
         for (int i = layer; i < Inspector.gameObjects.Length; i++)
         {
             Inspector.RemoveAllFromGUI(Inspector.gameObjects[i]);
             Inspector.gameObjects[i] = new List <CustomGUI>();
         }
         float             j          = 0.2f;
         List <GameObject> transforms = new List <GameObject>();
         if (!parentObject)
         {
             foreach (Scene scene in SceneManager.GetAllScenes())
             {
                 transforms.AddRange(new List <GameObject>(scene.GetRootGameObjects()));
             }
         }
         else
         {
             transforms = new List <GameObject>();
             foreach (object obj in parentObject.transform)
             {
                 Transform transform = (Transform)obj;
                 transforms.Add(transform.gameObject);
             }
         }
         using (List <GameObject> .Enumerator enumerator2 = transforms.GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 GameObject gameObject = enumerator2.Current;
                 Button     button4    = new Button(new Rect(0.1f * (float)layer, j, 0.1f, 0.02f), gameObject.name, JMTKGUI.GUIElement.Button, delegate()
                 {
                     try
                     {
                         Inspector.CreateList(gameObject);
                     }
                     catch (Exception e2)
                     {
                         Debug.Log(e2 + "\n" + e2.StackTrace);
                     }
                 });
                 j += 0.02f;
                 Inspector.gameObjects[layer].Add(button4);
             }
         }
         Inspector.AddAllToGUI(Inspector.gameObjects[layer]);
     }
     catch (Exception e)
     {
         Debug.Log(e + "\n" + e.StackTrace);
     }
 }