Beispiel #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);
 }
Beispiel #2
0
    public static void InspectComponent(Component component)
    {
        float startX = 0.8f;

        Inspector.RemoveAllFromGUI(Inspector.componentFields);
        if (!component)
        {
            return;
        }
        Inspector.componentFields.Add(new TextGUIElement(new Rect(startX, 0.4f - Inspector.unitHeight, 0.2f, Inspector.unitHeight), component.name + " Fields", JMTKGUI.GUIElement.Label, null));
        Inspector.componentFields = new List <CustomGUI>();
        int i = 0;

        foreach (PropertyInfo field in component.GetType().GetProperties())
        {
            try
            {
                Tuple <List <CustomGUI>, int> tuple = Inspector.CreateEditField(component, field, new Rect(0.8f, 0.4f + Inspector.unitHeight * (float)i, 0.2f, Inspector.unitHeight));
                List <CustomGUI> editFields         = tuple.Item1;
                int height = tuple.Item2;
                i += height;
                if (editFields != null)
                {
                    Inspector.AddAllToGUI(editFields);
                    Inspector.componentFields.AddRange(editFields);
                }
                else
                {
                    Debug.Log(string.Concat(new object[]
                    {
                        "Key: ",
                        field.Name,
                        " Value: ",
                        field.GetValue(component)
                    }));
                }
            }
            catch (Exception e)
            {
                Debug.Log("Issue with " + field.Name);
                Debug.Log(string.Concat(new object[]
                {
                    "Inspector problem with field: " + field.Name + " \nException: ",
                    e,
                    "\n",
                    e.StackTrace
                }));
            }
        }
    }
Beispiel #3
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);
     }
 }