static bool GetIsValid(ShowToggleAttribute toggle, SerializedProperty property) { if (toggle.IsEnum) { return(GetIsValidEnum(toggle, property)); } return(GetIsValidBool(toggle, property)); }
static bool GetIsValidEnum(ShowToggleAttribute toggle, SerializedProperty property) { var propertyPath = property.propertyPath; var conditionPath = propertyPath.Replace(property.name, toggle.fieldName); var condition = property.serializedObject.FindProperty(conditionPath); if (condition != null) { return(toggle.requiredEnumValue.Contains(condition.enumValueIndex)); } Debug.LogWarningFormat("[ShowToggle] could not find attribute {0}", toggle.fieldName); return(true); }
static ShowToggleDisplay GetDisplay(ShowToggleAttribute toggle, SerializedProperty property) { var isValid = GetIsValid(toggle, property); return(isValid ? toggle.validDisplay : toggle.invalidDisplay); }