Ejemplo n.º 1
0
        public static bool DrawButton(this UnityLabel current, GUIStyle style = null, bool indention = true)
        {
            style = style ?? GUI.skin.button;
            var layout = style.CreateLayout() ?? EditorUI.CreateLayout();

            return(EditorUI.Draw(() => GUILayout.Button(current, style, layout), indention));
        }
Ejemplo n.º 2
0
        public static Enum Draw(this Enum current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.popup;
            var layout = style.CreateLayout() ?? EditorUI.CreateLayout();

            return(EditorUI.Draw(() => EditorGUILayout.EnumPopup(label, current, style, layout), indention));
        }
Ejemplo n.º 3
0
        public static int Draw(this IEnumerable <string> current, int index, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.popup;
            var labelValue = label.IsNull() ? null : label.ToString();

            return(EditorUI.Draw(() => EditorGUILayout.Popup(labelValue, index, current.ToArray(), style), indention));
        }
Ejemplo n.º 4
0
        public static float Draw(this float current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.numberField;
            var layout = style.CreateLayout() ?? EditorUI.CreateLayout();

            return(EditorUI.Draw(() => EditorGUILayout.FloatField(label, current, style, layout), indention));
        }
Ejemplo n.º 5
0
        public static bool Draw(this bool current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.toggle;
            var layout = style.CreateLayout() ?? EditorUI.CreateLayout();

            return(EditorUI.Draw(() => EditorGUILayout.Toggle(label, current, style, layout), indention));
        }
Ejemplo n.º 6
0
        public static int Draw(this IEnumerable <string> current, Rect area, int index, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.popup;
            string name = label.IsNull() ? "" : label.ToString();

            return(EditorUI.Draw <int>(() => EditorGUI.Popup(area, name, index, current.ToArray(), style), indention, area));
        }
Ejemplo n.º 7
0
        public static void DrawLabel(this UnityLabel current, UnityLabel label, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.label;
            var layout = style.CreateLayout() ?? EditorUI.CreateLayout();

            EditorUI.Draw(() => EditorGUILayout.LabelField(label, current, style, layout), indention);
        }
Ejemplo n.º 8
0
        public static string DrawTextArea(this string current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.textField;
            var layout = style.CreateLayout() ?? EditorUI.CreateLayout();

            return(EditorUI.Draw(() => EditorGUILayout.TextField(label, current, style, layout), indention));
        }
Ejemplo n.º 9
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);
     }
     EditorUI.Draw(() => EditorGUI.PropertyField(area, current, label, allowScene), indention, area);
 }
Ejemplo n.º 10
0
        public static IEnumerable <bool> DrawFlags(this IEnumerable <string> current, IEnumerable <bool> active, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.popup;
            var layout = style.CreateLayout() ?? EditorUI.CreateLayout();
            var mask   = EditorUI.Draw(() => EditorGUILayout.MaskField(label, active.ToBitFlags(), current.ToArray(), style, layout), indention);

            return(mask.ToFlags(active.Count()));
        }
Ejemplo n.º 11
0
 public static Enum DrawMaskField(this Enum current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.popup;
                 #if UNITY_2017_3_OR_NEWER
     return(EditorUI.Draw <Enum>(() => EditorGUI.EnumFlagsField(area, label, current, style), indention, area));
                 #else
     return(EditorUI.Draw <Enum>(() => EditorGUI.EnumMaskField(area, label, current, style), indention, area));
                 #endif
 }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        public static float DrawSlider(this float current, Rect area, float min, float max, bool indention = true)
        {
            var value = EditorUI.Draw <float>(() => GUI.HorizontalSlider(area, current, min, max), indention, area);

            if (value != current)
            {
                GUI.FocusControl("");
            }
            return(value);
        }
Ejemplo n.º 14
0
        public static Enum DrawFlags(this Enum current, UnityLabel label = null, GUIStyle style = null, bool indention = true)
        {
            style = style ?? EditorStyles.popup;
            var layout = style.CreateLayout() ?? EditorUI.CreateLayout();

                        #if UNITY_2017_3_OR_NEWER
            return(EditorUI.Draw(() => EditorGUILayout.EnumFlagsField(label, current, style, layout), indention));
                        #else
            return(EditorUI.Draw(() => EditorGUILayout.EnumMaskField(label, current, style, layout), indention));
                        #endif
        }
Ejemplo n.º 15
0
        public static void DrawHelp(this string current, Rect area, string textType, bool indention = true)
        {
            MessageType type = MessageType.None;

            if (textType.Contains("Info", true))
            {
                type = MessageType.Info;
            }
            if (textType.Contains("Error", true))
            {
                type = MessageType.Error;
            }
            if (textType.Contains("Warning", true))
            {
                type = MessageType.Warning;
            }
            EditorUI.Draw(() => EditorGUI.HelpBox(area, current, type), indention, area);
        }
Ejemplo n.º 16
0
 public static Rect Draw(this Rect current, Rect area, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <Rect>(() => EditorGUI.RectField(area, label, current), indention, area));
 }
Ejemplo n.º 17
0
 public static Vector4 DrawVector4(this Vector4 current, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw(() => EditorGUILayout.Vector4Field(label.ToString(), current, EditorUI.CreateLayout()), indention));
 }
Ejemplo n.º 18
0
 public static Enum Draw(this Enum current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.popup;
     return(EditorUI.Draw <Enum>(() => EditorGUI.EnumPopup(area, label, current, style), indention, area));
 }
Ejemplo n.º 19
0
 public static bool Draw(this bool current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.toggle;
     return(EditorUI.Draw <bool>(() => EditorGUI.Toggle(area, label, current, style), indention, area));
 }
Ejemplo n.º 20
0
 public static AnimationCurve Draw(this AnimationCurve current, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw(() => EditorGUILayout.CurveField(label, current, EditorUI.CreateLayout()), indention));
 }
Ejemplo n.º 21
0
 public static void DrawLabel(this UnityLabel current, Rect area, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.label;
     EditorUI.Draw(() => EditorGUI.LabelField(area, current, style), indention, area);
 }
Ejemplo n.º 22
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)EditorUI.Draw <UnityObject>(() => EditorGUI.ObjectField(area, label, current, typeof(Type), allowScene), indention, area));
 }
Ejemplo n.º 23
0
        public static Vector4 DrawVector4(this Vector4 current, Rect area, UnityLabel label = null, bool indention = true)
        {
            string name = label.IsNull() ? null : label.ToString();

            return(EditorUI.Draw <Vector3>(() => EditorGUI.Vector4Field(area, name, current), indention, area));
        }
Ejemplo n.º 24
0
 public static Vector3 DrawVector3(this Vector3 current, Rect area, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <Vector3>(() => EditorGUI.Vector3Field(area, label, current), indention, area));
 }
Ejemplo n.º 25
0
 public static bool DrawButton(this UnityLabel current, Rect area, GUIStyle style = null, bool indention = true)
 {
     style = style ?? GUI.skin.button;
     return(EditorUI.Draw <bool>(() => GUI.Button(area, current, style), indention, area));
 }
Ejemplo n.º 26
0
 public static AnimationCurve Draw(this AnimationCurve current, Rect area, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <AnimationCurve>(() => EditorGUI.CurveField(area, label, current), indention, area));
 }
Ejemplo n.º 27
0
 public static Color Draw(this Color current, Rect area, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw <Color>(() => EditorGUI.ColorField(area, label, current), indention, area));
 }
Ejemplo n.º 28
0
 public static string Draw(this string current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.textField;
     return(EditorUI.Draw <string>(() => EditorGUI.TextField(area, label, current, style), indention, area));
 }
Ejemplo n.º 29
0
 public static float Draw(this float current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true)
 {
     style = style ?? EditorStyles.numberField;
     return(EditorUI.Draw <float>(() => EditorGUI.FloatField(area, label, current, style), indention, area));
 }
Ejemplo n.º 30
0
 public static Color Draw(this Color current, UnityLabel label = null, bool indention = true)
 {
     return(EditorUI.Draw(() => EditorGUILayout.ColorField(label, current, EditorUI.CreateLayout()), indention));
 }