protected override PropertyCondition OnGuiValidateSafe(SerializedProperty property, T attribute) { var propertyToCheck = property.GetSibiling(attribute.ComparedPropertyName); if (propertyToCheck == null) { ToolboxEditorLog.PropertyNotFoundWarning(property, attribute.ComparedPropertyName); return(PropertyCondition.Valid); } //TODO: validate 'propertyToCheck' type with 'attribute.ComparedConditionValue' switch (propertyToCheck.propertyType) { case SerializedPropertyType.Boolean: return(OnComparisonResult(propertyToCheck.boolValue.Equals(attribute.ComparedConditionValue))); case SerializedPropertyType.String: return(OnComparisonResult(propertyToCheck.stringValue.Equals(attribute.ComparedConditionValue))); case SerializedPropertyType.Integer: return(OnComparisonResult(propertyToCheck.intValue.Equals(attribute.ComparedConditionValue))); case SerializedPropertyType.Float: return(OnComparisonResult(propertyToCheck.floatValue.Equals(attribute.ComparedConditionValue))); case SerializedPropertyType.Enum: return(OnComparisonResult(propertyToCheck.intValue.Equals((int)attribute.ComparedConditionValue))); default: ToolboxEditorLog.TypeNotSupportedWarning(property, propertyToCheck.type); return(PropertyCondition.Valid); } }
protected override PropertyCondition OnGuiValidateSafe(SerializedProperty property, T attribute) { var propertyToCheck = property.GetSibiling(attribute.PropertyName); if (propertyToCheck == null) { ToolboxEditorLog.PropertyNotFoundWarning(property, attribute.PropertyName); return(PropertyCondition.Valid); } //TODO: validate 'propertyToCheck' type with 'attribute.ValueToMatch' var result = true; switch (propertyToCheck.propertyType) { case SerializedPropertyType.Integer: result = ComparisionHelper.CheckInteger(propertyToCheck, attribute.ValueToMatch, attribute.TestMethod); break; case SerializedPropertyType.Boolean: result = ComparisionHelper.CheckBoolean(propertyToCheck, attribute.ValueToMatch, attribute.TestMethod); break; case SerializedPropertyType.Float: result = ComparisionHelper.CheckFloat(propertyToCheck, attribute.ValueToMatch, attribute.TestMethod); break; case SerializedPropertyType.String: result = ComparisionHelper.CheckString(propertyToCheck, attribute.ValueToMatch, attribute.TestMethod); break; case SerializedPropertyType.ObjectReference: result = ComparisionHelper.CheckObject(propertyToCheck, attribute.ValueToMatch, attribute.TestMethod); break; case SerializedPropertyType.Enum: result = ComparisionHelper.CheckEnum(propertyToCheck, attribute.ValueToMatch, attribute.TestMethod); break; default: ToolboxEditorLog.TypeNotSupportedWarning(property, propertyToCheck.type); break; } return(OnComparisonResult(result)); }
protected bool IsConditionMet(SerializedProperty property, T attribute) { if (attribute == null) { return(true); } var propertyToCheck = property.serializedObject.FindProperty(attribute.ComparedPropertyName); if (propertyToCheck == null) { ToolboxEditorLog.PropertyNotFoundWarning(property, attribute.ComparedPropertyName); return(true); } switch (propertyToCheck.propertyType) { case SerializedPropertyType.Boolean: return(propertyToCheck.boolValue.Equals(attribute.ComparedConditionValue)); case SerializedPropertyType.String: return(propertyToCheck.stringValue.Equals(attribute.ComparedConditionValue)); case SerializedPropertyType.Integer: return(propertyToCheck.intValue.Equals(attribute.ComparedConditionValue)); case SerializedPropertyType.Float: return(propertyToCheck.floatValue.Equals(attribute.ComparedConditionValue)); case SerializedPropertyType.Enum: return(propertyToCheck.intValue.Equals((int)attribute.ComparedConditionValue)); default: ToolboxEditorLog.TypeNotSupportedWarning(property, propertyToCheck.type); return(true); } }