示例#1
0
        private bool GetIsVisible(EnabledIfAttribute attribute, SerializedProperty property)
        {
            if (GetIsEnabled(attribute, property))
            {
                return(true);
            }

            if (attribute.hideMode != EnabledIfAttribute.HideMode.Invisible)
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        private int GetSwitcherPropertyValue(EnabledIfAttribute attribute, SerializedProperty property)
        {
            var propertyNameIndex    = property.propertyPath.LastIndexOf(property.name, StringComparison.Ordinal);
            var switcherPropertyName =
                property.propertyPath.Substring(0, propertyNameIndex) + attribute.switcherFieldName;
            var switcherProperty = property.serializedObject.FindProperty(switcherPropertyName);

            switch (switcherProperty.propertyType)
            {
            case SerializedPropertyType.Boolean:
                return(switcherProperty.boolValue ? 1 : 0);

            case SerializedPropertyType.Enum:
                return(switcherProperty.intValue);

            default:
                throw new Exception("unsupported type.");
            }
        }
示例#3
0
 private bool GetIsEnabled(EnabledIfAttribute attribute, SerializedProperty property)
 {
     return(attribute.enableIfValueIs == GetSwitcherPropertyValue(attribute, property));
 }