Esempio n. 1
0
        /// <inheritdoc />
        protected override void ValidateProperty(SerializedPropertyAttributeWrapper wrapper, MaxValueAttribute attribute)
        {
            var property = wrapper.Property;

            switch (property.propertyType)
            {
            case SerializedPropertyType.Integer:
                if (property.intValue > attribute.MaxValue)
                {
                    property.intValue = (int)attribute.MaxValue;
                }
                break;

            case SerializedPropertyType.Float:
                if (property.floatValue > attribute.MaxValue)
                {
                    property.floatValue = attribute.MaxValue;
                }
                break;

            default:
                NotIntFloat();
                break;
            }
        }
Esempio n. 2
0
        private static void DrawRequiredBox(SerializedPropertyAttributeWrapper wrapper, RequiredAttribute attribute)
        {
            string errorMessage = wrapper.DisplayName + " is required";

            if (!string.IsNullOrEmpty(attribute.Message))
            {
                errorMessage = attribute.Message;
            }

            EditorDrawUtility.DrawHelpBox(errorMessage, MessageType.Error);
        }
Esempio n. 3
0
        /// <inheritdoc />
        protected override void DrawProperty(SerializedPropertyAttributeWrapper wrapper, ProgressBarAttribute attribute)
        {
            var property = wrapper.Property;

            if (property.propertyType != SerializedPropertyType.Float && property.propertyType != SerializedPropertyType.Integer)
            {
                NotIntFloat(wrapper);
                return;
            }

            var value = property.propertyType == SerializedPropertyType.Integer ? property.intValue : property.floatValue;

            this.DrawProgressBar(value, property.propertyType == SerializedPropertyType.Integer, attribute);
        }
Esempio n. 4
0
        /// <inheritdoc />
        protected override void DrawProperty(SerializedPropertyAttributeWrapper wrapper, ShowAssetPreviewAttribute attribute)
        {
            var property = wrapper.Property;

            if (property.propertyType != SerializedPropertyType.ObjectReference)
            {
                NotObject(wrapper);
                return;
            }

            wrapper.DrawDefaultField();

            DrawPreview(property.objectReferenceValue, attribute);
        }
Esempio n. 5
0
        /// <inheritdoc />
        protected override void DrawProperty(SerializedPropertyAttributeWrapper wrapper, ResizableTextAreaAttribute attribute)
        {
            var property = wrapper.Property;

            if (property.propertyType != SerializedPropertyType.String)
            {
                NotString(wrapper);
                return;
            }

            if (DrawField(wrapper.DisplayName, property.stringValue, out var textAreaValue))
            {
                property.stringValue = textAreaValue;
            }
        }
Esempio n. 6
0
        /// <inheritdoc />
        protected override void ValidateProperty(SerializedPropertyAttributeWrapper wrapper, RequiredAttribute attribute)
        {
            var property = wrapper.Property;

            if (property.propertyType != SerializedPropertyType.ObjectReference)
            {
                NotObject();
                return;
            }

            if (property.objectReferenceValue == null)
            {
                DrawRequiredBox(wrapper, attribute);
            }
        }
        /// <inheritdoc />
        protected override void DrawProperty(SerializedPropertyAttributeWrapper wrapper, MinMaxSliderAttribute attribute)
        {
            var property = wrapper.Property;

            if (property.propertyType != SerializedPropertyType.Vector2)
            {
                NotVector2Field(wrapper);
                return;
            }

            var sliderValue = property.vector2Value;

            if (this.DrawProperty(wrapper.DisplayName, ref sliderValue, attribute))
            {
                property.vector2Value = sliderValue;
            }
        }
        /// <inheritdoc />
        protected override void DrawProperty(SerializedPropertyAttributeWrapper wrapper, SliderAttribute attribute)
        {
            var property = wrapper.Property;

            switch (property.propertyType)
            {
            case SerializedPropertyType.Integer:
                property.intValue = EditorGUILayout.IntSlider(property.intValue, (int)attribute.MinValue, (int)attribute.MaxValue);
                break;

            case SerializedPropertyType.Float:
                property.floatValue = EditorGUILayout.Slider(property.floatValue, attribute.MinValue, attribute.MaxValue);
                break;

            default:
                NotIntFloat(wrapper);
                break;
            }
        }
Esempio n. 9
0
        public void ApplyPropertyMeta(SerializedPropertyAttributeWrapper wrapper, OnValueChangedAttribute attribute)
        {
            var target = wrapper.Target;

            var callbackMethod = ReflectionUtility.GetMethod(target, attribute.CallbackName);

            if (callbackMethod != null &&
                callbackMethod.ReturnType == typeof(void) &&
                callbackMethod.GetParameters().Length == 0)
            {
                // We must apply modifications so that the callback can be invoked with up-to-date data
                wrapper.Property.serializedObject.ApplyModifiedProperties();

                callbackMethod.Invoke(target, null);
            }
            else
            {
                string warning = attribute.GetType().Name + " can invoke only action methods - with void return type and no parameters";
                EditorDrawUtility.DrawHelpBox(warning, MessageType.Warning);
            }
        }
 /// <inheritdoc />
 protected override void ValidateProperty(SerializedPropertyAttributeWrapper wrapper,
                                          ValidateInputAttribute attribute)
 {
     ValidateProperty(wrapper, attribute);
 }
Esempio n. 11
0
 protected abstract void ValidateProperty(SerializedPropertyAttributeWrapper wrapper, T attribute);
Esempio n. 12
0
        /// <inheritdoc />
        public override void Run(SerializedPropertyAttributeWrapper wrapper, NaughtyAttribute attribute)
        {
            Assert.IsTrue(attribute is T);

            this.ValidateProperty(wrapper, (T)attribute);
        }
 /// <inheritdoc />
 protected override void DrawProperty(SerializedPropertyAttributeWrapper wrapper, DropdownAttribute attribute)
 {
     this.DrawProperty(wrapper, attribute);
 }
 public abstract void Run(SerializedPropertyAttributeWrapper wrapper, NaughtyAttribute attribute);