This commit is contained in:
CortexCore
2025-03-04 20:32:30 +08:00
parent 42eb7b00d9
commit 268c24de0d
3 changed files with 8 additions and 14 deletions

View File

@@ -8,19 +8,10 @@ namespace BITKit
{
public class Tag : MonoBehaviour,ITag
{
[Header(Constant.Header.Settings)]
[Tooltip("It's will be deprecated in the future, use reference instead.")]
[SerializeField] private string[] tags;
[Tooltip("Disable when tags is not empty")]
[SerializeReference,SubclassSelector] private IReference[] reference;
public int Hash => _id is 0 ? _id = MathE.GetHash(GetTags()) : _id;
public int Hash => _id is 0 ? _id = MathE.GetHash(Tags) : _id;
private int _id;
public string[] GetTags() => CacheTags ??= reference?.Length > 0 ? reference.Select(x => x.Value).ToArray() : tags;
private string[] CacheTags;
public void SetTags(IReference[] newReference)
{
reference = newReference;
CacheTags = null;
}
public IReadOnlyCollection<string> Tags=> _cacheTags ??= reference.Select(x => x.Value).ToArray();
private string[] _cacheTags;
}
}