private bool GetIsVisible(EnabledIfAttribute attribute, SerializedProperty property) { if (GetIsEnabled(attribute, property)) { return(true); } if (attribute.hideMode != EnabledIfAttribute.HideMode.Invisible) { return(true); } return(false); }
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."); } }
private bool GetIsEnabled(EnabledIfAttribute attribute, SerializedProperty property) { return(attribute.enableIfValueIs == GetSwitcherPropertyValue(attribute, property)); }