diff --git a/Editor/Validators/GameObject/GameObjectValidatorDuplicateComponents.cs b/Editor/Validators/GameObject/GameObjectValidatorDuplicateComponents.cs index 1ea0509..eaf89a1 100644 --- a/Editor/Validators/GameObject/GameObjectValidatorDuplicateComponents.cs +++ b/Editor/Validators/GameObject/GameObjectValidatorDuplicateComponents.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Reflection; using UnityEngine; using UnityEngine.Pool; @@ -28,7 +30,7 @@ namespace Module.ProjectValidator.Editor } else { - if (count > 1) + if (count > 1 && IsMultipleComponentsAllowed(type)) results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"GameObject has duplicate '{type.Name}' ({count}) components")); type = t; @@ -36,8 +38,13 @@ namespace Module.ProjectValidator.Editor } } - if (count > 1) + if (count > 1 && IsMultipleComponentsAllowed(type)) results.Add(ValidatorResult.Create(EValidatorSeverity.Warning, $"GameObject has duplicate '{type.Name}' ({count}) components")); } + + private static bool IsMultipleComponentsAllowed(Type type) + { + return type.GetCustomAttribute(true) == null; + } } } \ No newline at end of file