public static Enum Draw(this Enum current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.popup;
            var layout = style.CreateLayout() ?? Class.CreateLayout();

            return(EditorUI.Draw <Enum>(() => EditorGUILayout.EnumPopup(label, current, style, layout), indention));
        }
        public static string Draw(this string current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.textField;
            var layout = style.CreateLayout() ?? Class.CreateLayout();

            return(EditorUI.Draw <string>(() => EditorGUILayout.TextField(label, current, style, layout), indention));
        }
        public static bool Draw(this bool current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.toggle;
            var layout = style.CreateLayout() ?? Class.CreateLayout();

            return(EditorUI.Draw <bool>(() => EditorGUILayout.Toggle(label, current, style, layout), indention));
        }
        public static float Draw(this float current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.numberField;
            var layout = style.CreateLayout() ?? Class.CreateLayout();

            return(EditorUI.Draw <float>(() => EditorGUILayout.FloatField(label, current, style, layout), indention));
        }
        public static bool DrawButton(this UnityLabel current, GUIStyle style = null, bool indention = true)
        {
            style = style ?? GUI.skin.button;
            var layout = style.CreateLayout() ?? Class.CreateLayout();

            return(EditorUI.Draw <bool>(() => GUILayout.Button(current, style, layout), indention));
        }
Example #6
0
 public static void Draw(this SerializedProperty current, Rect area, UnityLabel label = null, bool allowScene = true, bool indention = true)
 {
     if (label != null && label.value.text.IsEmpty())
     {
         label = new GUIContent(current.displayName);
     }
     EditorGUIExtension.Draw(() => EditorGUI.PropertyField(area, current, label, allowScene), indention);
 }
 public static void DrawLabel(this UnityLabel current, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.label;
     if (indention)
     {
         EditorGUIExtension.Draw(() => EditorGUILayout.LabelField(current, style, style.CreateLayout()), indention);
         return;
     }
     EditorGUIExtension.Draw(() => GUILayout.Label(current, style), indention);
 }
Example #8
0
        public static void Draw(this SerializedProperty current, UnityLabel label = null, bool allowScene = true, bool indention = true)
        {
            if (label != null && label.value.text.IsEmpty())
            {
                label = new GUIContent(current.displayName);
            }
            Action action = () => EditorGUILayout.PropertyField(current, label, allowScene, EditorUI.CreateLayout());

            EditorUI.Draw(action, indention);
        }
Example #9
0
        public static void DrawLabel(this UnityLabel current, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.label;
            var layout = style.CreateLayout() ?? Class.CreateLayout();

            if (indention)
            {
                EditorUI.Draw(() => EditorGUILayout.LabelField(current, style, layout), indention);
                return;
            }
            EditorUI.Draw(() => GUILayout.Label(current, style, layout), indention);
        }
        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;
        }
Example #11
0
 //public static void DrawLabel(this string current,GUIStyle style=null,bool indention=true){new UnityLabel(current).DrawLabel(style,indention);}
 //public static void DrawLabel(this GUIContent current,GUIStyle style=null,bool indention=true){new UnityLabel(current).DrawLabel(style,indention);}
 public static void DrawLabel(this UnityLabel current, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.label;
     if (indention)
     {
         var options = new List <GUILayoutOption>();
         if (style.fixedWidth != 0)
         {
             options.Add(GUILayout.Width(style.fixedWidth));
         }
         EditorGUIExtension.Draw(() => EditorGUILayout.LabelField(current, style, options.ToArray()), indention);
         return;
     }
     EditorGUIExtension.Draw(() => GUILayout.Label(current, style), indention);
 }
Example #12
0
        public static bool DrawFoldout(this UnityLabel current, Rect area, object key, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.foldout;
            string name = key.IsNull() ? current + "Foldout" : key.GetHashCode().ToString();

            if (key is string)
            {
                name = (string)key;
            }
            bool previous = EditorPrefs.GetBool(name);
            bool state    = EditorGUIExtension.Draw <bool>(() => EditorGUI.Foldout(area, previous, current, style), indention);

            if (previous != state)
            {
                EditorPrefs.SetBool(name, state);
            }
            return(state);
        }
Example #13
0
        public static bool DrawHeader(this UnityLabel current, Rect area, object key, GUIStyle style = null, bool indention = true)
        {
            string stateName = key.IsNull() ? current + "Foldout" : key.GetHashCode().ToString();

            if (key is string)
            {
                stateName = (string)key;
            }
            bool state = EditorPrefs.GetBool(stateName);

            current = state ? "▼ " + current : "▶ " + current;
            var currentStyle = style.IsNull() ? null : new GUIStyle(style);

            if (state)
            {
                currentStyle.normal = currentStyle.active;
            }
            if (current.DrawButton(area, currentStyle, indention))
            {
                state = !state;
                EditorPrefs.SetBool(stateName, state);
            }
            return(state);
        }
Example #14
0
        public static Enum DrawMask(this Enum current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.popup;
            string value     = current.ToName().Replace(" ", " | ").ToTitleCase();
            Rect   valueArea = area;

            if (!label.IsNull())
            {
                Rect labelArea = area.AddWidth(-EditorGUIUtility.labelWidth);
                valueArea = labelArea.AddX(EditorGUIUtility.labelWidth);
                if (value.IsEmpty())
                {
                    value = "None";
                }
                label.DrawLabel(labelArea, null, true);
            }
            if (GUI.Button(valueArea, value.Trim("| "), style))
            {
                var items = current.ToName().Split(" ").ToTitleCase();
                GenericMenu.MenuFunction2 callback = index => {
                    EditorGUIExtensionSpecial.menuArea  = area;
                    EditorGUIExtensionSpecial.menuValue = current.GetValues().GetValue((int)index);
                };
                current.GetNames().ToTitleCase().DrawMenu(valueArea, callback, items);
            }
            if (EditorGUIExtensionSpecial.menuArea == area && !EditorGUIExtensionSpecial.menuValue.IsNull())
            {
                var menuValue = (Enum)EditorGUIExtensionSpecial.menuValue;
                var newValue  = current.ToInt() ^ menuValue.ToInt();
                current = (Enum)Enum.ToObject(current.GetType(), newValue);
                EditorGUIExtensionSpecial.menuValue = null;
                EditorGUIExtensionSpecial.menuArea  = new Rect();
                GUI.changed = true;
            }
            return(current);
        }
Example #15
0
 public static Enum DrawMaskField(this Enum current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.popup;
     return(EditorGUIExtension.Draw <Enum>(() => EditorGUI.EnumMaskField(area, label, current, style), indention));
 }
Example #16
0
 public static Vector4 DrawVector4(this Vector4 current, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <Vector4>(() => EditorGUILayout.Vector4Field(label.ToString(), current, EditorUI.CreateLayout()), indention));
 }
Example #17
0
 public static Vector3 DrawVector3(this Vector3 current, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <Vector3>(() => EditorGUILayout.Vector3Field(label, current, EditorUI.CreateLayout()), indention));
 }
Example #18
0
 public static Type Draw <Type>(this UnityObject current, UnityLabel label = null, bool allowScene = true, bool indention = true) where Type : UnityObject
 {
     return((Type)EditorUI.Draw <UnityObject>(() => EditorGUILayout.ObjectField(label, current, typeof(Type), allowScene, EditorUI.CreateLayout()), indention));
 }
Example #19
0
 public static float DrawSlider(this float current, float min, float max, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <float>(() => EditorGUILayout.Slider(label, current, min, max, EditorUI.CreateLayout()), indention));
 }
Example #20
0
 public static int DrawSlider(this int current, int min, int max, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <int>(() => EditorGUILayout.IntSlider(label, current, min, max, EditorUI.CreateLayout()), indention));
 }
Example #21
0
 public static Color Draw(this Color current, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <Color>(() => EditorGUILayout.ColorField(label, current, EditorUI.CreateLayout()), indention));
 }
Example #22
0
 public static Rect Draw(this Rect current, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <Rect>(() => EditorGUILayout.RectField(label, current, EditorUI.CreateLayout()), indention));
 }
Example #23
0
 //public static void DrawLabel(this string current,Rect area,GUIStyle style=null,bool indention=true){new UnityLabel(current).DrawLabel(area,style,indention);}
 //public static void DrawLabel(this GUIContent current,Rect area,GUIStyle style=null,bool indention=true){new UnityLabel(current).DrawLabel(area,style,indention);}
 public static void DrawLabel(this UnityLabel current, Rect area, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.label;
     EditorGUIExtension.Draw(() => EditorGUI.LabelField(area, current, style), indention);
 }
Example #24
0
 public static int DrawInt(this int current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.numberField;
     return(EditorGUIExtension.Draw <int>(() => EditorGUI.IntField(area, label, current, style), indention));
 }
Example #25
0
 //public static bool DrawButton(this string current,Rect area,GUIStyle style=null,bool indention=true){return new UnityLabel(current).DrawButton(area,style,indention);}
 //public static bool DrawButton(this GUIContent current,Rect area,GUIStyle style=null,bool indention=true){return new UnityLabel(current).DrawButton(area,style,indention);}
 public static bool DrawButton(this UnityLabel current, Rect area, GUIStyle style = null, bool indention = true)
 {
     style = style ?? GUI.skin.button;
     return(EditorGUIExtension.Draw <bool>(() => GUI.Button(area, current, style), indention));
 }
Example #26
0
 public static string DrawTextArea(this string current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.textField;
     return(EditorGUIExtension.Draw <string>(() => EditorGUI.TextField(area, label, current, style), indention));
 }
Example #27
0
 public static AnimationCurve Draw(this AnimationCurve current, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <AnimationCurve>(() => EditorGUILayout.CurveField(label, current, EditorUI.CreateLayout()), indention));
 }
Example #28
0
 public static Vector3 DrawVector3(this Vector3 current, Rect area, UnityLabel label = null, bool indention = true)
 {
     return(EditorGUIExtension.Draw <Vector3>(() => EditorGUI.Vector3Field(area, label, current), indention));
 }
Example #29
0
 public static Type Draw <Type>(this UnityObject current, Rect area, UnityLabel label = null, bool allowScene = true, bool indention = true) where Type : UnityObject
 {
     return((Type)EditorGUIExtension.Draw <UnityObject>(() => EditorGUI.ObjectField(area, label, current, typeof(Type), allowScene), indention));
 }
Example #30
0
        public static Vector4 DrawVector4(this Vector4 current, Rect area, UnityLabel label = null, bool indention = true)
        {
            string name = label.IsNull() ? null : label.ToString();

            return(EditorGUIExtension.Draw <Vector3>(() => EditorGUI.Vector4Field(area, name, current), indention));
        }