private bool GetVisible(SerializedProperty property, ConditionalDisplayAttribute attribute) { var path = property.propertyPath; var index = property.propertyPath.LastIndexOf('.'); var conditionPath = index > 0 ? path.Substring(0, index) + "." + attribute.Property : attribute.Property; var conditionProperty = property.serializedObject.FindProperty(conditionPath); if (conditionProperty != null) { switch (conditionProperty.propertyType) { case SerializedPropertyType.Integer: return(conditionProperty.intValue == attribute.IntValue); case SerializedPropertyType.Boolean: return(conditionProperty.boolValue == attribute.BoolValue); case SerializedPropertyType.Float: return(conditionProperty.floatValue == attribute.FloatValue); case SerializedPropertyType.String: return(conditionProperty.stringValue == attribute.StringValue); case SerializedPropertyType.ObjectReference: return(conditionProperty.objectReferenceValue == attribute.HasReference); case SerializedPropertyType.Enum: return(conditionProperty.intValue == attribute.EnumValue); default: Debug.LogWarningFormat(_invalidPropertyType, property.propertyPath, attribute.Property); break; } } else { Debug.LogWarningFormat(_invalidPropertyWarning, property.propertyPath, attribute.Property); } return(true); }
public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute) { base.Setup(property, fieldInfo, attribute); _attribute = attribute as ConditionalDisplayAttribute; }