mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
fix MetaID duplicate exception
This commit is contained in:
parent
2d1c61ef37
commit
907f1ae083
@ -520,14 +520,23 @@ namespace DCFApixels.DragonECS
|
||||
string id = atr.ID;
|
||||
if (type.IsGenericType && type.IsGenericTypeDefinition == false)
|
||||
{
|
||||
id = $"{id}<{string.Join(", ", type.GetGenericArguments().Select(o => GetMetaID(o)))}>";
|
||||
var metaIds = type.GetGenericArguments().Select(o => GetMetaID(o));
|
||||
if(metaIds.Any(o => string.IsNullOrEmpty(o)))
|
||||
{
|
||||
id = string.Empty;
|
||||
}
|
||||
if (_idTypePairs.TryGetValue(id, out Type otherType) && type != otherType) //этот ексепшен не работает, так как атрибуты не кешируются а пересоздаются
|
||||
else
|
||||
{
|
||||
id = $"{id}<{string.Join(", ", metaIds)}>";
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(id) == false &&
|
||||
_idTypePairs.TryGetValue(id, out Type otherType) && type != otherType)
|
||||
{
|
||||
Throw.Exception($"Types {type.ToMeta().TypeName} and {otherType.ToMeta().TypeName} have duplicate {atr.ID} MetaID.");
|
||||
}
|
||||
_idTypePairs[atr.ID] = type;
|
||||
return atr.ID;
|
||||
_idTypePairs[id] = type;
|
||||
return id;
|
||||
}
|
||||
#else
|
||||
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetMetaID)} method does not work.");
|
||||
|
Loading…
Reference in New Issue
Block a user