Exemplo n.º 1
0
 public static void DrawFields(this object current, string header = "Fields")
 {
     if (header.IsEmpty() || EditorGUILayoutExtensionSpecial.DrawFoldout(header))
     {
         if (!header.IsEmpty())
         {
             EditorGUI.indentLevel += 1;
         }
         foreach (var item in current.GetVariables())
         {
             string label = item.Key.ToTitleCase();
             object field = item.Value;
             if (field is ICollection)
             {
                 var enumerable = field as IEnumerable;
                 enumerable.OfType <object>().ToList().Draw(label);
                 continue;
             }
             if (field.GetType().IsClass&& field.GetType().IsSerializable&& !(field is string))
             {
                 field.DrawFields(label);
                 continue;
             }
             string value = Convert.ToString(field);
             if (value != null)
             {
                 value.Draw(label);
             }
         }
         if (!header.IsEmpty())
         {
             EditorGUI.indentLevel -= 1;
         }
     }
 }
Exemplo n.º 2
0
 public static void Draw <T>(this IList <T> current, string header = "List")
 {
     if (header.IsEmpty() || EditorGUILayoutExtensionSpecial.DrawFoldout(header))
     {
         if (!header.IsEmpty())
         {
             EditorGUI.indentLevel += 1;
         }
         for (int index = 0; index < current.Count; ++index)
         {
             var    item  = current[index];
             string label = "#" + index;
             if (item is ICollection)
             {
                 var enumerable = item as IEnumerable;
                 enumerable.OfType <object>().ToList().Draw(label);
                 continue;
             }
             if (!item.IsNull() && item.GetType() != typeof(UnityObject) && item.GetType().IsClass&& item.GetType().IsSerializable&& !(item is string))
             {
                 item.DrawFields(label);
                 continue;
             }
             item.DrawAuto(label);
         }
         if (!header.IsEmpty())
         {
             EditorGUI.indentLevel -= 1;
         }
     }
 }
Exemplo n.º 3
0
        public static void Draw(this IDictionary current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            var open = EditorGUILayoutExtensionSpecial.DrawFoldout(label.ToString().ToTitleCase(), Class.CreateLayout());

            if (!open)
            {
                return;
            }
            EditorGUI.indentLevel += 1;
            foreach (DictionaryEntry item in current)
            {
                item.Value.DrawAuto(item.Key.ToString(), style, true);
            }
            EditorGUI.indentLevel -= 1;
        }