Validator: Duplicate component validator is now only run on types without DisallowMultipleComponent attribute
This commit is contained in:
parent
ed3c02a0aa
commit
3802ca557c
1 changed files with 10 additions and 3 deletions
|
|
@ -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<DisallowMultipleComponent>(true) == null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue