diff --git a/Source/Engine/Content/Cache/AssetsCache.cpp b/Source/Engine/Content/Cache/AssetsCache.cpp index 71faef533..f8d3433ed 100644 --- a/Source/Engine/Content/Cache/AssetsCache.cpp +++ b/Source/Engine/Content/Cache/AssetsCache.cpp @@ -405,38 +405,42 @@ void AssetsCache::RegisterAssets(FlaxStorage* storage) void AssetsCache::RegisterAsset(const Guid& id, const String& typeName, const StringView& path) { PROFILE_CPU(); - ScopeLock lock(_locker); - // Mark registry as draft - _isDirty = true; - // Check if asset has been already added to the registry bool isMissing = true; for (auto i = _registry.Begin(); i.IsNotEnd(); ++i) { auto& e = i->Value; - // Compare IDs if (e.Info.ID == id) { - // Update registry entry - e.Info.Path = path; - e.Info.TypeName = typeName; - - // Back + if (e.Info.Path != path) + { + e.Info.Path = path; + _isDirty = true; + } + if (e.Info.TypeName != typeName) + { + e.Info.TypeName = typeName; + _isDirty = true; + } isMissing = false; break; } - // Compare paths if (e.Info.Path == path) { - // Update registry entry - e.Info.ID = id; - e.Info.TypeName = typeName; - - // Back + if (e.Info.ID != id) + { + e.Info.Path = path; + _isDirty = true; + } + if (e.Info.TypeName != typeName) + { + e.Info.TypeName = typeName; + _isDirty = true; + } isMissing = false; break; } @@ -445,9 +449,8 @@ void AssetsCache::RegisterAsset(const Guid& id, const String& typeName, const St if (isMissing) { LOG(Info, "Register asset {0}:{1} \'{2}\'", id, typeName, path); - - // Add new asset entry _registry.Add(id, Entry(id, typeName, path)); + _isDirty = true; } } diff --git a/Source/Engine/ContentImporters/CreateJson.cpp b/Source/Engine/ContentImporters/CreateJson.cpp index 54381dcbb..862c5028f 100644 --- a/Source/Engine/ContentImporters/CreateJson.cpp +++ b/Source/Engine/ContentImporters/CreateJson.cpp @@ -9,6 +9,7 @@ #include "Engine/Platform/FileSystem.h" #include "Engine/Content/Content.h" #include "Engine/Content/Storage/JsonStorageProxy.h" +#include "Engine/Content/Cache/AssetsCache.h" #include "Engine/Content/AssetReference.h" #include "Engine/Serialization/JsonWriters.h" #include "Engine/Localization/LocalizedStringTable.h" @@ -54,7 +55,7 @@ bool CreateJson::Create(const StringView& path, StringAnsiView& data, StringAnsi LOG(Warning, "Failed to create directory"); return true; } - } + } } rapidjson_flax::StringBuffer buffer; @@ -91,6 +92,10 @@ bool CreateJson::Create(const StringView& path, StringAnsiView& data, StringAnsi { asset->Reload(); } + else + { + Content::GetRegistry()->RegisterAsset(id, String(dataTypename), path); + } return false; }