Fix loaded asset verification error for json assets that have the scripting type

This commit is contained in:
Wojtek Figat
2020-12-21 14:03:53 +01:00
parent 585c752d72
commit aa7711dc31

View File

@@ -872,7 +872,7 @@ Asset* Content::LoadAsync(const Guid& id, const ScriptingTypeHandle& type)
if (result)
{
// Validate type
if (IsAssetTypeIdInvalid(type, result->GetTypeHandle()))
if (IsAssetTypeIdInvalid(type, result->GetTypeHandle()) && !result->Is(type))
{
LOG(Warning, "Different loaded asset type! Asset: \'{0}\'. Expected type: {1}", result->ToString(), type.ToString());
return nullptr;
@@ -945,15 +945,6 @@ Asset* Content::load(const Guid& id, const ScriptingTypeHandle& type, AssetInfo&
return nullptr;
}
// Validate type
const StringAsANSI<> typeNameStd(assetInfo.TypeName.Get(), assetInfo.TypeName.Length());
const auto assetType = Scripting::FindScriptingType(StringAnsiView(typeNameStd.Get(), assetInfo.TypeName.Length()));
if (IsAssetTypeIdInvalid(type, assetType))
{
LOG(Error, "Different loaded asset type! Asset: '{0}'. Expected type: {1}", assetInfo.ToString(), type.ToString());
return nullptr;
}
#endif
// Find asset factory based in its type
@@ -972,6 +963,18 @@ Asset* Content::load(const Guid& id, const ScriptingTypeHandle& type, AssetInfo&
return nullptr;
}
#if ASSETS_LOADING_EXTRA_VERIFICATION
// Validate type
if (IsAssetTypeIdInvalid(type, result->GetTypeHandle()) && !result->Is(type))
{
LOG(Error, "Different loaded asset type! Asset: '{0}'. Expected type: {1}", assetInfo.ToString(), type.ToString());
result->DeleteObject();
return nullptr;
}
#endif
// Register asset
{
AssetsLocker.Lock();