Esempio n. 1
0
        bool CompareInt(ShowIfAttribute showIf, int comparedProperty)
        {
            //compare property A and value
            switch (showIf.comparisonType)
            {
            case ShowIfAttribute.EComparisonType.isEqual:
                return(comparedProperty == (int)showIf.valueToCompare);

            case ShowIfAttribute.EComparisonType.isNotEqual:
                return(comparedProperty != (int)showIf.valueToCompare);

            case ShowIfAttribute.EComparisonType.isGreater:
                return(comparedProperty > (int)showIf.valueToCompare);

            case ShowIfAttribute.EComparisonType.isGreaterEqual:
                return(comparedProperty >= (int)showIf.valueToCompare);

            case ShowIfAttribute.EComparisonType.isLower:
                return(comparedProperty < (int)showIf.valueToCompare);

            case ShowIfAttribute.EComparisonType.isLowerEqual:
                return(comparedProperty <= (int)showIf.valueToCompare);

            default:
                return(comparedProperty == (int)showIf.valueToCompare);
            }
        }
Esempio n. 2
0
 bool CompareBool(ShowIfAttribute showIf, bool comparedProperty)
 {
     //equal
     if (showIf.comparisonType == ShowIfAttribute.EComparisonType.isEqual)
     {
         return(comparedProperty == (bool)showIf.valueToCompare);
     }
     //not equal
     else if (showIf.comparisonType == ShowIfAttribute.EComparisonType.isNotEqual)
     {
         return(comparedProperty != (bool)showIf.valueToCompare);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 3
0
        bool CanShow(SerializedProperty property)
        {
            ShowIfAttribute showIf = attribute as ShowIfAttribute;

            SerializedProperty comparedProperty = property.serializedObject.FindProperty(showIf.propertyA);

            //compare property based on propertyType
            if (comparedProperty.propertyType == SerializedPropertyType.Boolean)
            {
                return(CompareBool(showIf, comparedProperty.boolValue));
            }
            else if (comparedProperty.propertyType == SerializedPropertyType.Enum)
            {
                return(CompareInt(showIf, comparedProperty.enumValueIndex));
            }
            else if (comparedProperty.propertyType == SerializedPropertyType.Integer)
            {
                return(CompareInt(showIf, comparedProperty.intValue));
            }

            return(false);
        }