using System.Reflection; namespace jeanf.propertyDrawer { using UnityEngine; using System; /// /// Draws the field/property ONLY if the copared property compared by the comparison type with the value of comparedValue returns true. /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)] public class DrawIfAttribute : PropertyAttribute { public string comparedPropertyName { get; private set; } public object comparedValue { get; private set; } public ComparisonType comparisonType { get; private set; } public DisablingType disablingType { get; private set; } /// /// Only draws the field only if a condition is met. /// /// The name of the property that is being compared (case sensitive). /// The value the property is being compared to. /// The type of comparison the values will be compared by. /// The type of disabling that should happen if the condition is NOT met. Defaulted to DisablingType.DontDraw. public DrawIfAttribute(string comparedPropertyName, object comparedValue, ComparisonType comparisonType, DisablingType disablingType = DisablingType.DontDraw) { this.comparedPropertyName = comparedPropertyName; this.comparedValue = comparedValue; this.comparisonType = comparisonType; this.disablingType = disablingType; } } }