Пример #1
0
        public override void OnGUI(Rect position, MaterialProperty property, string label, MaterialEditor editor)
        {
            EditorUI.Reset();
            Vector2 limits    = property.rangeLimits;
            float   value     = property.floatValue;
            float   labelSize = EditorGUIUtility.labelWidth;

            property.displayName.ToLabel().DrawLabel(position.SetWidth(labelSize));
            position = position.AddX(labelSize).AddWidth(-labelSize - 69);
            if (limits != Vector2.zero)
            {
                value = value.DrawSlider(position, limits.x, limits.y);
            }
            value = value.ToInt();
            value = value.Draw(position.AddX(position.width + 5).SetWidth(64));
            property.floatValue = (float)value;
        }
Пример #2
0
        public bool IsVisible(Rect area, Rect region, Vector2 scroll)
        {
            bool fixedX  = area.AddX(-scroll.x).Overlaps(region);
            bool fixedY  = area.AddY(-scroll.y).Overlaps(region);
            bool fixedXY = area.AddXY(-scroll).Overlaps(region);
            bool normal  = area.Overlaps(region);

            return(normal || fixedX || fixedY || fixedXY);
        }
Пример #3
0
        public override void OnGUI(Rect area, SerializedProperty property, GUIContent label)
        {
            EditorUI.Reset();
            Transition     transition    = property.GetObject <Transition>();
            float          durationValue = transition.duration.Get();
            float          delayValue    = transition.delayStart.Get();
            AnimationCurve curveValue    = transition.curve;
            Rect           labelRect     = area.SetWidth(EditorGUIUtility.labelWidth);
            Rect           valueRect     = area.Add(labelRect.width, 0, -labelRect.width, 0);

            label.ToLabel().DrawLabel(labelRect, null, true);
            durationValue = durationValue.Draw(valueRect.SetWidth(35));
            "seconds".ToLabel().DrawLabel(valueRect.AddX(37).SetWidth(50));
            delayValue = delayValue.Draw(valueRect.AddX(90).SetWidth(35));
            "delay".ToLabel().DrawLabel(valueRect.AddX(127).SetWidth(40));
            curveValue = transition.curve.Draw(valueRect.Add(169, 0, -169, 0));
            if (GUI.changed)
            {
                transition.duration.Set(durationValue);
                transition.delayStart.Set(delayValue);
                transition.curve = curveValue;
            }
        }
    public override void OnGUI(Rect p, SerializedProperty property, GUIContent label)
    {
        var min = property.FindPropertyRelative("Min");
        var max = property.FindPropertyRelative("Max");

        var minVal = min.floatValue;
        var maxVal = max.floatValue;

        EditorGUI.BeginChangeCheck();
        EditorGUI.MinMaxSlider(p = p.SetHeight(18), label, ref minVal, ref maxVal, 0, 10);

        p = p.AddY(20);
        p = EditorGUI.PrefixLabel(p, new GUIContent(" "));

        minVal = EditorGUI.FloatField(p.AddX(-15).SetWidth(100), minVal);
        maxVal = EditorGUI.FloatField(p.AddX(p.width - 100).SetWidth(100), maxVal);

        if (EditorGUI.EndChangeCheck())
        {
            min.floatValue = Mathf.Min(minVal, maxVal);
            max.floatValue = Mathf.Max(minVal, maxVal);
        }
    }
Пример #5
0
        public override void OnGUI(Rect area, SerializedProperty property, GUIContent label)
        {
            EditorUI.Reset();
            string[]    names     = new string[] { "X", "Y", "Z", "W" };
            List <bool> data      = property.GetObject <ListBool>().value;
            Rect        labelRect = area.SetWidth(EditorGUIUtility.labelWidth);
            Rect        valueRect = area.Add(labelRect.width, 0, -labelRect.width, 0);

            label.ToLabel().DrawLabel(labelRect, null, true);
            for (int index = 0; index < data.Count; ++index)
            {
                data[index] = data[index].Draw(valueRect.AddX((index * 30)).SetWidth(30));
                names[index].ToLabel().DrawLabel(valueRect.Add(14 + (index * 30)));
            }
        }
Пример #6
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);
        }
Пример #7
0
 public static Rect AddXY(this Rect current, float x, float y)
 {
     return(current.AddX(x).AddY(y));
 }
Пример #8
0
 public static Rect AddXY(this Rect current, Vector2 value)
 {
     return(current.AddX(value.x).AddY(value.y));
 }