/// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            ValueResolver.DrawErrors(this.minGetter, this.maxGetter, this.vector2IntMinMaxGetter);

            // Get the range of the slider from the attribute or from member references.
            Vector2 range;

            if (this.vector2IntMinMaxGetter != null && !this.vector2IntMinMaxGetter.HasError)
            {
                range = (Vector2)this.vector2IntMinMaxGetter.GetValue();
            }
            else
            {
                range.x = this.minGetter.GetValue();
                range.y = this.maxGetter.GetValue();
            }

            EditorGUI.BeginChangeCheck();
            Vector2 value = SirenixEditorFields.MinMaxSlider(label, (Vector2)this.ValueEntry.SmartValue, range, this.Attribute.ShowFields);

            if (EditorGUI.EndChangeCheck())
            {
                this.ValueEntry.SmartValue = new Vector2Int((int)value.x, (int)value.y);
            }
        }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            // Get the range of the slider from the attribute or from member references.
            Vector2 range;

            if (vector2IntMinMaxGetter != null && errorMessage == null)
            {
                range = (Vector2)vector2IntMinMaxGetter.GetValue();
            }
            else
            {
                if (intMinGetter != null)
                {
                    range.x = intMinGetter.GetValue();
                }
                else if (floatMinGetter != null)
                {
                    range.x = floatMinGetter.GetValue();
                }
                else
                {
                    range.x = Attribute.MinValue;
                }

                if (intMaxGetter != null)
                {
                    range.y = intMaxGetter.GetValue();
                }
                else if (floatMaxGetter != null)
                {
                    range.y = floatMaxGetter.GetValue();
                }
                else
                {
                    range.y = Attribute.MaxValue;
                }
            }

            // Display evt. error message.
            if (errorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(errorMessage);
            }

            EditorGUI.BeginChangeCheck();
            var value = SirenixEditorFields.MinMaxSlider(label, (Vector2)ValueEntry.SmartValue, range,
                                                         Attribute.ShowFields);

            if (EditorGUI.EndChangeCheck())
            {
                ValueEntry.SmartValue = new Vector2Int((int)value.x, (int)value.y);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            //Vector2 range;
            //if (this.vector2MinMaxGetter != null && this.errorMessage == null)
            //{
            //    range = this.vector2MinMaxGetter.GetValue();
            //}
            //else
            //{
            //    if (this.intMinGetter != null)
            //    {
            //        range.x = this.intMinGetter.GetValue();
            //    }
            //    else if (this.floatMinGetter != null)
            //    {
            //        range.x = this.floatMinGetter.GetValue();
            //    }
            //    else
            //    {
            //        range.x = this.Attribute.MinValue;
            //    }

            //    if (this.intMaxGetter != null)
            //    {
            //        range.y = this.intMaxGetter.GetValue();
            //    }
            //    else if (this.floatMaxGetter != null)
            //    {
            //        range.y = this.floatMaxGetter.GetValue();
            //    }
            //    else
            //    {
            //        range.y = this.Attribute.MaxValue;
            //    }
            //}
            Vector2 range = this.rangeGetter.GetValue();

            if (this.errorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(this.errorMessage);
            }

            this.ValueEntry.SmartValue = SirenixEditorFields.MinMaxSlider(label, this.ValueEntry.SmartValue, range, this.Attribute.ShowFields);
        }
 /// <summary>
 /// Draws the property.
 /// </summary>
 protected override void DrawPropertyLayout(IPropertyValueEntry <Vector2> entry, MinMaxSliderAttribute attribute, GUIContent label)
 {
     entry.SmartValue = SirenixEditorFields.MinMaxSlider(label, entry.SmartValue, new Vector2(attribute.MinValue, attribute.MaxValue), attribute.ShowFields);
 }