diff --git a/Source/Engine/Content/Content.cpp b/Source/Engine/Content/Content.cpp index 78d0ff1d6..8d43a7318 100644 --- a/Source/Engine/Content/Content.cpp +++ b/Source/Engine/Content/Content.cpp @@ -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();