/// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            // TODO: There's currently no SirenixEditorFields.DoubleRangeField, so we're making do with the float field. This should be fixed.
            double value = this.ValueEntry.SmartValue;

            if (value < float.MinValue)
            {
                value = float.MinValue;
            }
            else if (value > float.MaxValue)
            {
                value = float.MaxValue;
            }

            double min = this.getterMinValue != null?this.getterMinValue.GetValue() : this.Attribute.Min;

            double max = this.getterMaxValue != null?this.getterMaxValue.GetValue() : this.Attribute.Max;

            if (this.getterMinValue != null && this.getterMinValue.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(this.getterMinValue.ErrorMessage);
            }
            if (this.getterMaxValue != null && this.getterMaxValue.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(this.getterMaxValue.ErrorMessage);
            }

            EditorGUI.BeginChangeCheck();
            value = SirenixEditorFields.RangeFloatField(label, (float)value, (float)Math.Min(min, max), (float)Math.Max(min, max));
            if (EditorGUI.EndChangeCheck())
            {
                this.ValueEntry.SmartValue = value;
            }
        }
        /// <summary>
        ///  Draws a slider for the passed <see cref="SerializedProperty"/> values.
        /// </summary>
        /// <param name="valueProp"></param>
        /// <param name="minProp"></param>
        /// <param name="maxProp"></param>
        public static void DrawClampRangeLayout(
            SerializedProperty valueProp,
            SerializedProperty minProp,
            SerializedProperty maxProp)
        {
            var valueType = GetType(valueProp);

            if (SUPPORTED_INT_TYPES.Contains(valueType))
            {
                #if ODIN_INSPECTOR
                valueProp.intValue = SirenixEditorFields.RangeIntField(
                    new GUIContent(valueProp.displayName),
                    valueProp.intValue,
                    minProp.intValue,
                    maxProp.intValue);
                #else
                EditorGUILayout.IntSlider(valueProp, minProp.intValue, maxProp.intValue);
                #endif
            }
            else if (SUPPORTED_FLOAT_TYPES.Contains(valueType))
            {
                #if ODIN_INSPECTOR
                valueProp.floatValue = SirenixEditorFields.RangeFloatField(
                    new GUIContent(valueProp.displayName),
                    valueProp.floatValue,
                    minProp.floatValue,
                    maxProp.floatValue);
                #else
                EditorGUILayout.Slider(valueProp, minProp.floatValue, maxProp.floatValue);
                #endif
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <decimal> entry, PropertyRangeAttribute attribute, GUIContent label)
        {
            EditorGUI.BeginChangeCheck();
            float value = SirenixEditorFields.RangeFloatField(label, (float)entry.SmartValue, (float)attribute.Min, (float)attribute.Max);

            if (EditorGUI.EndChangeCheck())
            {
                entry.SmartValue = (decimal)value;
            }
        }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var entry     = this.ValueEntry;
            var attribute = this.Attribute;

            EditorGUI.BeginChangeCheck();
            float value = SirenixEditorFields.RangeFloatField(label, (float)entry.SmartValue, attribute.min, attribute.max);

            if (EditorGUI.EndChangeCheck())
            {
                entry.SmartValue = (decimal)value;
            }
        }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            decimal min = this.getterMinValue != null?this.getterMinValue.GetValue() : (decimal)this.Attribute.Min;

            decimal max = this.getterMaxValue != null?this.getterMaxValue.GetValue() : (decimal)this.Attribute.Max;

            if (this.getterMinValue != null && this.getterMinValue.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(this.getterMinValue.ErrorMessage);
            }
            if (this.getterMaxValue != null && this.getterMaxValue.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(this.getterMaxValue.ErrorMessage);
            }

            EditorGUI.BeginChangeCheck();
            float value = SirenixEditorFields.RangeFloatField(label, (float)this.ValueEntry.SmartValue, (float)Math.Min(min, max), (float)Math.Max(min, max));

            if (EditorGUI.EndChangeCheck())
            {
                this.ValueEntry.SmartValue = (decimal)value;
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Draws the property.
 /// </summary>
 protected override void DrawPropertyLayout(IPropertyValueEntry <float> entry, PropertyRangeAttribute attribute, GUIContent label)
 {
     entry.SmartValue = SirenixEditorFields.RangeFloatField(label, entry.SmartValue, (float)attribute.Min, (float)attribute.Max);
 }