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;
|
string id = atr.ID;
|
||||||
if (type.IsGenericType && type.IsGenericTypeDefinition == false)
|
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;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id = $"{id}<{string.Join(", ", metaIds)}>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (_idTypePairs.TryGetValue(id, out Type otherType) && type != otherType) //этот ексепшен не работает, так как атрибуты не кешируются а пересоздаются
|
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.");
|
Throw.Exception($"Types {type.ToMeta().TypeName} and {otherType.ToMeta().TypeName} have duplicate {atr.ID} MetaID.");
|
||||||
}
|
}
|
||||||
_idTypePairs[atr.ID] = type;
|
_idTypePairs[id] = type;
|
||||||
return atr.ID;
|
return id;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetMetaID)} method does not work.");
|
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetMetaID)} method does not work.");
|
||||||
|
Loading…
Reference in New Issue
Block a user