Esempio n. 1
0
        // Draw the property inside the given rect
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // First get the attribute since it contains the range for the slider
            MinMaxAttribute minMax = attribute as MinMaxAttribute;

            Vector2 interval = property.vector2Value;

            Rect sliderPosition = position;

            sliderPosition.width -= valueWidth * 2;

            EditorGUI.MinMaxSlider(sliderPosition, label, ref interval.x, ref interval.y, minMax.min, minMax.max);

            Rect valuePosition = position;

            valuePosition.x     = sliderPosition.x + sliderPosition.width;
            valuePosition.width = valueWidth;

            Vector2 roundedInterval = interval;

            roundedInterval.x = GetRoundedValue(roundedInterval.x);
            roundedInterval.y = GetRoundedValue(roundedInterval.y);

            interval.x = EditorGUI.FloatField(valuePosition, interval.x);

            valuePosition.x += valueWidth;

            interval.y = EditorGUI.FloatField(valuePosition, interval.y);

            property.vector2Value = interval;
        }
Esempio n. 2
0
 private void DisplayOptions(Type type, StringBuilder sb)
 {
     FieldInfo[] fields = type.GetFields();
     foreach (FieldInfo info in fields)
     {
         if (info.FieldType == typeof(int) || info.FieldType == typeof(uint) || info.FieldType == typeof(double))
         {
             MinMaxAttribute minMaxAttribute = info.GetCustomAttribute(typeof(MinMaxAttribute)) as MinMaxAttribute;
             if (minMaxAttribute != null)
             {
                 sb.AppendLine("/" + info.Name + " = [" + minMaxAttribute.Min.ToString() + ", " + minMaxAttribute.Max.ToString() + "]");
             }
             else
             {
                 ValidValuesAttribute validValuesAttribute = info.GetCustomAttribute(typeof(ValidValuesAttribute)) as ValidValuesAttribute;
                 if (validValuesAttribute != null)
                 {
                     sb.AppendLine("/" + info.Name + " = " + string.Join(" | ", validValuesAttribute.ValidValues));
                 }
             }
         }
         else if (info.FieldType == typeof(bool))
         {
             sb.AppendLine("/" + info.Name + " = true | false");
         }
         else if (info.FieldType.IsEnum)
         {
             sb.AppendLine("/" + info.Name + " = " + string.Join(" | ", Enum.GetNames(info.FieldType)));
         }
     }
 }
Esempio n. 3
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     try
     {
         string Value;
         if (!(value is string))
         {
             Value = Convert.ChangeType(value, context.PropertyDescriptor.PropertyType).ToString();
         }
         else
         {
             Value = value as string;
         }
         decimal decVal;
         if (!decimal.TryParse(Value, out decVal))
         {
             decVal = decimal.One;
         }
         MinMaxAttribute attr = (MinMaxAttribute)context.PropertyDescriptor.Attributes[typeof(MinMaxAttribute)];
         if (attr != null)
         {
             decVal = attr.PutInRange(decVal);
         }
         return(Convert.ChangeType(decVal, context.PropertyDescriptor.PropertyType));
     }
     catch
     {
         return(base.ConvertFrom(context, culture, value));
     }
 }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            try
            {
                Type underlyingType = Nullable.GetUnderlyingType(context.PropertyDescriptor.PropertyType) ?? context.PropertyDescriptor.PropertyType;

                string Value = value as string;
                if (!(value is string))
                {
                    Value = Convert.ChangeType(value, underlyingType).ToString();
                }

                decimal decVal;
                if (!decimal.TryParse(Value, out decVal))
                {
                    if (Nullable.GetUnderlyingType(context.PropertyDescriptor.PropertyType) != null)
                    {
                        // it is a nullable we can safely return null
                        return(null);
                    }
                    decVal = decimal.One;
                }

                MinMaxAttribute attr = (MinMaxAttribute)context.PropertyDescriptor.Attributes[typeof(MinMaxAttribute)];
                if (attr != null)
                {
                    decVal = attr.PutInRange(decVal);
                }
                return(Convert.ChangeType(decVal, underlyingType));
            }
            catch
            {
                return(base.ConvertFrom(context, culture, value));
            }
        }
Esempio n. 5
0
        private void SetMinMaxValue(ITypeDescriptorContext context)
        {
            MinMaxAttribute attribute = context.PropertyDescriptor.Attributes[typeof(MinMaxAttribute)] as MinMaxAttribute;

            if (attribute != null)
            {
                min = attribute.MinValue;
                max = attribute.MaxValue;
            }
            if (max <= min)
            {
                min          = 0;
                max          = 100;
                defaultValue = 0;
            }
            DefaultValueAttribute defaultVal = context.PropertyDescriptor.Attributes[typeof(DefaultValueAttribute)] as DefaultValueAttribute;

            if (defaultVal != null && defaultVal.Value is int)
            {
                defaultValue = (int)defaultVal.Value;
            }
            else
            {
                if (defaultValue > max)
                {
                    defaultValue = max;
                }
                if (defaultValue < min)
                {
                    defaultValue = min;
                }
            }
        }
Esempio n. 6
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        // cast the attribute to make life easier
        MinMaxAttribute minMax = attribute as MinMaxAttribute;

        // This only works on a vector2! ignore on any other property type (we should probably draw an error message instead!)
        if (property.propertyType == SerializedPropertyType.Vector2)
        {
            // if we are flagged to draw in a special mode, lets modify the drawing rectangle to draw only one line at a time
            if (minMax.ShowDebugValues || minMax.ShowEditRange)
            {
                position = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
            }

            // pull out a bunch of helpful min/max values....
            float minValue = property.vector2Value.x; // the currently set minimum and maximum value
            float maxValue = property.vector2Value.y;
            float minLimit = minMax.MinLimit;         // the limit for both min and max, min cant go lower than minLimit and maax cant top maxLimit
            float maxLimit = minMax.MaxLimit;

            // and ask unity to draw them all nice for us!
            EditorGUI.MinMaxSlider(position, label, ref minValue, ref maxValue, minLimit, maxLimit);

            var vec = Vector2.zero; // save the results into the property!
            vec.x = minValue;
            vec.y = maxValue;

            property.vector2Value = vec;

            // Do we have a special mode flagged? time to draw lines!
            if (minMax.ShowDebugValues || minMax.ShowEditRange)
            {
                bool isEditable = false;
                if (minMax.ShowEditRange)
                {
                    isEditable = true;
                }

                if (!isEditable)
                {
                    GUI.enabled = false; // if were just in debug mode and not edit mode, make sure all the UI is read only!
                }
                // move the draw rect on by one line
                position.y += EditorGUIUtility.singleLineHeight;

                Vector4 val = new Vector4(minLimit, minValue, maxValue, maxLimit); // shove the values and limits into a vector4 and draw them all at once
                val = EditorGUI.Vector4Field(position, "MinLimit/MinVal/MaxVal/MaxLimit", val);

                GUI.enabled = false; // the range part is always read only
                position.y += EditorGUIUtility.singleLineHeight;
                EditorGUI.FloatField(position, "Selected Range", maxValue - minValue);
                GUI.enabled = true; // remember to make the UI editable again!

                if (isEditable)
                {
                    property.vector2Value = new Vector2(val.y, val.z); // save off any change to the value~
                }
            }
        }
    }
Esempio n. 7
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // cast the attribute to make life easier
            MinMaxAttribute minMax  = attribute as MinMaxAttribute;
            var             boxRect = new Rect(position.x - 2, position.y - 2, position.width + 4, position.height + 4);

            GUI.Box(boxRect, GUIContent.none);

            var sliderRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
            var rect       = new Rect(position.x + EditorGUIUtility.labelWidth, position.y + EditorGUIUtility.singleLineHeight, 50, EditorGUIUtility.singleLineHeight);

            if (property.propertyType == SerializedPropertyType.Vector2Int)
            {
                float minValue = property.vector2IntValue.x; // the currently set minimum and maximum value
                float maxValue = property.vector2IntValue.y;
                float minLimit = minMax.MinLimit;            // the limit for both min and max, min cant go lower than minLimit and max cant top maxLimit
                float maxLimit = minMax.MaxLimit;


                EditorGUI.MinMaxSlider(sliderRect, label, ref minValue, ref maxValue, minLimit, maxLimit);
                minValue = EditorGUI.IntField(rect, (int)minValue);
                rect.x  += 60;
                maxValue = EditorGUI.IntField(rect, (int)maxValue);
                if (maxValue < minValue)
                {
                    maxValue = minValue;
                }

                var vec = Vector2Int.zero; // save the results into the property!
                vec.x = (int)minValue;
                vec.y = (int)maxValue;
                property.vector2IntValue = vec;
            }

            if (property.propertyType == SerializedPropertyType.Vector2)
            {
                float minValue = property.vector2Value.x; // the currently set minimum and maximum value
                float maxValue = property.vector2Value.y;
                float minLimit = minMax.MinLimit;         // the limit for both min and max, min cant go lower than minLimit and max cant top maxLimit
                float maxLimit = minMax.MaxLimit;

                EditorGUI.MinMaxSlider(sliderRect, label, ref minValue, ref maxValue, minLimit, maxLimit);
                minValue = Mathf.Round(minValue * 1000f) / 1000f;
                maxValue = Mathf.Round(maxValue * 1000f) / 1000f;

                minValue = EditorGUI.FloatField(rect, minValue);
                rect.x  += 60;
                maxValue = EditorGUI.FloatField(rect, maxValue);
                if (maxValue < minValue)
                {
                    maxValue = minValue;
                }

                var vec = Vector2.zero; // save the results into the property!
                vec.x = minValue;
                vec.y = maxValue;
                property.vector2Value = vec;
            }
        }
Esempio n. 8
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        // cast the attribute to make life easier
        MinMaxAttribute minMax = attribute as MinMaxAttribute;

        // This only works on a vector2! ignore on any other property type (we should probably draw an error message instead!)
        if (property.propertyType == SerializedPropertyType.Vector2)
        {
            // if we are flagged to draw in a special mode, lets modify the drawing rectangle to draw only one line at a time
            if (minMax.ShowDebugValues || minMax.ShowEditRange)
            {
                position = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
            }

            // pull out a bunch of helpful min/max values....
            float minValue = property.vector2Value.x;
            float maxValue = property.vector2Value.y;
            float minLimit = minMax.MinLimit;
            float maxLimit = minMax.MaxLimit;

            EditorGUI.MinMaxSlider(position, label, ref minValue, ref maxValue, minLimit, maxLimit);

            var vec = Vector2.zero;
            vec.x = minValue;
            vec.y = maxValue;

            property.vector2Value = vec;

            if (minMax.ShowDebugValues || minMax.ShowEditRange)
            {
                bool isEditable = false;
                if (minMax.ShowEditRange)
                {
                    isEditable = true;
                }

                if (!isEditable)
                {
                    GUI.enabled = false;
                }

                position.y += EditorGUIUtility.singleLineHeight;

                GUI.enabled = false;
                Vector2 val = new Vector4(minValue, maxValue);
                val         = EditorGUI.Vector2Field(position, "", val);
                position.y += EditorGUIUtility.singleLineHeight;

                position.y += EditorGUIUtility.singleLineHeight;
                GUI.enabled = true;

                if (isEditable)
                {
                    property.vector2Value = new Vector2(val.x, val.y);
                }
            }
        }
    }
Esempio n. 9
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        MinMaxAttribute nP = attribute as MinMaxAttribute;

        SerializedProperty current = property.Copy();

        property.Next(false);
        SerializedProperty next = property;
        bool  isFloat           = current.propertyType == SerializedPropertyType.Float;
        float min   = isFloat ? current.floatValue : current.intValue;
        float max   = isFloat ? next.floatValue : next.intValue;
        float width = EditorGUIUtility.labelWidth;

        position.width -= width;
        Rect labelLeft = new Rect(position.x, position.y, width, position.height);

        EditorGUI.LabelField(labelLeft, nP.label);

        position = new Rect(labelLeft.xMax, position.y, position.width, position.height);
        float floatWidth  = position.width * 0.125f;
        float sliderWidth = position.width - floatWidth * 2;

        position.width = floatWidth;
        if (isFloat)
        {
            min = EditorGUI.FloatField(position, min);
        }
        else
        {
            min = (int)EditorGUI.IntField(position, (int)min);
        }
        position.x    += floatWidth;
        position.width = sliderWidth;
        EditorGUI.MinMaxSlider(position, ref min, ref max, nP.min, nP.max);
        position.x    += sliderWidth;
        position.width = floatWidth;
        max            = EditorGUI.FloatField(position, max);

        if (isFloat)
        {
            current.floatValue = min;
            next.floatValue    = max;
        }
        else
        {
            current.intValue = (int)min;
            next.intValue    = (int)max;
        }
    }
Esempio n. 10
0
    // this method lets unity know how big to draw the property. We need to override this because it could end up meing more than one line big
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        MinMaxAttribute minMax = attribute as MinMaxAttribute;

        // by default just return the standard line height
        float size = EditorGUIUtility.singleLineHeight;

        // if we have a special mode, add two extra lines!
        if (minMax.ShowEditRange || minMax.ShowDebugValues)
        {
            size += EditorGUIUtility.singleLineHeight * 2;
        }

        return(size);
    }
Esempio n. 11
0
        private void DrawMinMax(ref Rect lineRect, MinMaxAttribute minMax, SerializedProperty minProp, SerializedProperty maxProp)
        {
            var sliderRect = lineRect;

            var minValue = minProp.floatValue;
            var maxValue = maxProp.floatValue;

            //var minValue = EditorGUI.FloatField (minField, minProp.floatValue);
            //var maxValue = EditorGUI.FloatField (maxField, maxProp.floatValue);

            EditorGUI.MinMaxSlider(
                sliderRect, ref minValue, ref maxValue, (float)minMax.Min, (float)minMax.Max);

            minProp.floatValue = minValue;
            maxProp.floatValue = maxValue;
        }
Esempio n. 12
0
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        MinMaxAttribute minMax = attribute as MinMaxAttribute;


        float size = EditorGUIUtility.singleLineHeight;

        if (minMax.ShowEditRange || minMax.ShowDebugValues)
        {
            size += EditorGUIUtility.singleLineHeight * 2;
        }
        else
        {
            size += EditorGUIUtility.singleLineHeight;
        }
        return(size);
    }
Esempio n. 13
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        MinMaxAttribute minMax = attribute as MinMaxAttribute;

        if (property.type == nameof(RangeValue))
        {
            position.height = EditorGUIUtility.singleLineHeight;

            EditorGUI.BeginProperty(position, label, property);
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            var minProperty = property.FindPropertyRelative("Min");
            var maxProperty = property.FindPropertyRelative("Max");

            var minValue = minProperty.floatValue;
            var maxValue = maxProperty.floatValue;

            var sliderRect     = position;
            var floatFieldSize = 50;
            sliderRect.width -= floatFieldSize + floatFieldSize;
            sliderRect.x     += floatFieldSize;

            var max = Mathf.Max(minMax.Max, maxValue);
            EditorGUI.MinMaxSlider(sliderRect, GUIContent.none, ref minValue, ref maxValue, minMax.Min, max);

            minProperty.floatValue = minValue;
            maxProperty.floatValue = maxValue;

            var left = position;
            left.width = floatFieldSize;

            var right = left;
            right.x = position.x + position.width - left.width;

            minProperty.floatValue = EditorGUI.FloatField(left, GUIContent.none, minProperty.floatValue);
            maxProperty.floatValue = EditorGUI.FloatField(right, GUIContent.none, maxProperty.floatValue);



            EditorGUI.EndProperty();
        }
    }
Esempio n. 14
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Assert.IsTrue(property.propertyType == SerializedPropertyType.Vector2, TypeErrorMessage);

            if (property.propertyType == SerializedPropertyType.Vector2)
            {
                MinMaxAttribute minMaxAttribute = attribute as MinMaxAttribute;

                // The variable name on the left.
                Rect totalValueRect = EditorGUI.PrefixLabel(position, label);

                // The left value, after the variable name.
                Rect leftRect = new Rect(totalValueRect.x, totalValueRect.y, 50, totalValueRect.height);

                // Rect of the slider.
                Rect valueRect = new Rect(leftRect.xMax, totalValueRect.y,
                                          totalValueRect.width - leftRect.width * 2 - 4, totalValueRect.height);

                // The right value.
                Rect rightRect = new Rect(totalValueRect.xMax - leftRect.width - 2, totalValueRect.y,
                                          leftRect.width, totalValueRect.height);

                // Current x.
                float minValue = property.vector2Value.x;
                // Current y.
                float maxValue = property.vector2Value.y;

                EditorGUI.MinMaxSlider(valueRect, ref minValue, ref maxValue, minMaxAttribute.Min, minMaxAttribute.Max);

                // Assigns the value to the property.
                property.vector2Value = new Vector2(minValue, maxValue);

                // Writes the value on the left.
                EditorGUI.LabelField(leftRect, minValue.ToString("F3"));
                // Writes the value on the right.
                EditorGUI.LabelField(rightRect, maxValue.ToString("F3"));
            }
            else
            {
                GUI.Label(position, TypeErrorMessage);
            }
        }
Esempio n. 15
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     if (property.propertyType == SerializedPropertyType.Vector2)
     {
         Vector2         range             = property.vector2Value;
         float           min               = range.x;
         float           max               = range.y;
         MinMaxAttribute min_max_attribute = attribute as MinMaxAttribute;
         EditorGUI.BeginChangeCheck();
         EditorGUI.MinMaxSlider(label, position, ref min, ref max, min_max_attribute.Min, min_max_attribute.Max);
         if (EditorGUI.EndChangeCheck())
         {
             range.x = min;
             range.y = max;
             property.vector2Value = range;
         }
     }
     else
     {
         base.OnGUI(position, property, label);
     }
 }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            try
            {
                Type underlyingType = Nullable.GetUnderlyingType(context.PropertyDescriptor.PropertyType) ?? context.PropertyDescriptor.PropertyType;

                if (context == null || context.Instance == null || provider == null)
                {
                    return(value);
                }

                //use IWindowsFormsEditorService object to display a control in the dropdown area
                IWindowsFormsEditorService frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (frmsvr == null)
                {
                    return(value);
                }

                MinMaxAttribute attr = (MinMaxAttribute)context.PropertyDescriptor.Attributes[typeof(MinMaxAttribute)];
                if (attr != null)
                {
                    NumericUpDown nmr = new NumericUpDown
                    {
                        Size          = new Size(60, 120),
                        Minimum       = attr.Min,
                        Maximum       = attr.Max,
                        Increment     = attr.Increment,
                        DecimalPlaces = attr.DecimalPlaces,
                        Value         = (value == null) ? attr.PutInRange(Decimal.One) : attr.PutInRange(value)
                    };
                    frmsvr.DropDownControl(nmr);
                    context.OnComponentChanged();

                    return(Convert.ChangeType(nmr.Value, underlyingType));
                }
            }
            catch { }
            return(value);
        }
Esempio n. 17
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        MinMaxAttribute minMax = (MinMaxAttribute)this.attribute;

        var minProperty = property.FindPropertyRelative("min");
        var maxProperty = property.FindPropertyRelative("max");

        float minValue = minProperty.intValue;
        float maxValue = maxProperty.intValue;

        EditorGUI.MinMaxSlider(position, label, ref minValue, ref maxValue, minMax.MinLimit, minMax.MaxLimit);

        minProperty.intValue = (int)(minValue = Mathf.Round(minValue));
        maxProperty.intValue = (int)(maxValue = Mathf.Round(maxValue));

        GUI.enabled = false;
        position.y += EditorGUIUtility.singleLineHeight;
        EditorGUI.indentLevel++;
        EditorGUI.Vector2IntField(position, "Selected Range", new Vector2Int((int)minValue, (int)maxValue));
        EditorGUI.indentLevel--;
        GUI.enabled = true;
    }
Esempio n. 18
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        //Asserts that we're using the MinMax attribute on a Vector2
        UnityEngine.Assertions.Assert.IsTrue(property.propertyType == SerializedPropertyType.Vector2, "Devi usare un vector2 per MinMax");

        if (property.propertyType == SerializedPropertyType.Vector2)
        {
            MinMaxAttribute minMax = attribute as MinMaxAttribute;

            //Writes the variable name on the left
            Rect totalValueRect = EditorGUI.PrefixLabel(position, label);

            //The left value, after the variable name
            Rect leftRect = new Rect(totalValueRect.x, totalValueRect.y, 50, totalValueRect.height);

            //Rect of the slider
            Rect valueRect = new Rect(leftRect.xMax, totalValueRect.y, totalValueRect.width - leftRect.width * 2 - 4, totalValueRect.height);

            //The right value
            Rect rightRect = new Rect(totalValueRect.xMax - leftRect.width - 2, totalValueRect.y, leftRect.width, totalValueRect.height);

            float minValue = property.vector2Value.x; //Current x
            float maxValue = property.vector2Value.y; //Current y

            EditorGUI.MinMaxSlider(valueRect, ref minValue, ref maxValue, minMax.minLimit, minMax.maxLimit);

            //Assigns the value to the property
            property.vector2Value = new Vector2(minValue, maxValue);

            EditorGUI.LabelField(leftRect, minValue.ToString("F3"));  //Writes the value on the left
            EditorGUI.LabelField(rightRect, maxValue.ToString("F3")); //Writes the value on the right
        }
        else
        {
            GUI.Label(position, "You can use MinMax only on a Vector2!");
        }
    }
Esempio n. 19
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        MinMaxAttribute nP = attribute as MinMaxAttribute;

        DoSlider(nP.label, position, property, nP.min, nP.max);
    }
Esempio n. 20
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        MinMaxAttribute minMax = attribute as MinMaxAttribute;

        if (property.propertyType == SerializedPropertyType.Vector2)
        {
            if (minMax.ShowDebugValues || minMax.ShowEditRange)
            {
                position = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
            }


            float minValue = property.vector2Value.x;
            float maxValue = property.vector2Value.y;
            float minLimit = minMax.minLimit;
            float maxLimit = minMax.maxLimit;


            EditorGUI.MinMaxSlider(position, label, ref minValue, ref maxValue, minLimit, maxLimit);

            var vec = Vector2.zero;
            vec.x = minValue;
            vec.y = maxValue;

            property.vector2Value = vec;


            if (minMax.ShowDebugValues || minMax.ShowEditRange)
            {
                bool isEditable = false;
                if (minMax.ShowEditRange)
                {
                    isEditable = true;
                }

                if (!isEditable)
                {
                    GUI.enabled = false;
                }


                position.y += EditorGUIUtility.singleLineHeight;

                Vector4 val = new Vector4(minLimit, minValue, maxValue, maxLimit);
                val = EditorGUI.Vector4Field(position, "MinLimit/MinVal/MaxVal/MaxLimit", val);

                GUI.enabled = false;
                position.y += EditorGUIUtility.singleLineHeight;
                EditorGUI.FloatField(position, "Selected Range", maxValue - minValue);
                GUI.enabled = true;

                if (isEditable)
                {
                    property.vector2Value = new Vector2(val.y, val.z);
                }
            }
            else
            {
                GUI.enabled = false;
                position.y += EditorGUIUtility.singleLineHeight;
                EditorGUI.Vector2Field(position, "Current Values", new Vector2(minValue, maxValue));
                GUI.enabled = true;
            }
        }
    }
Esempio n. 21
0
        /***************************
         *******   METHODS   *******
         **************************/

        // Make your own IMGUI based GUI for the property
        public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label)
        {
            MinMaxAttribute _attribute = (MinMaxAttribute)attribute;

            EditorGUIEnhanced.MinMaxField(_position, _property, _label, _attribute.Minvalue, _attribute.MaxValue);
        }