diff --git a/Source/Engine/Content/Cache/AssetsCache.cpp b/Source/Engine/Content/Cache/AssetsCache.cpp index bd416fc8e..1cb7481d7 100644 --- a/Source/Engine/Content/Cache/AssetsCache.cpp +++ b/Source/Engine/Content/Cache/AssetsCache.cpp @@ -328,12 +328,17 @@ bool AssetsCache::FindAsset(const Guid& id, AssetInfo& info) return result; } +void AssetsCache::GetAll(Array& result) const +{ + PROFILE_CPU(); + ScopeLock lock(_locker); + _registry.GetKeys(result); +} + void AssetsCache::GetAllByTypeName(const StringView& typeName, Array& result) const { PROFILE_CPU(); - ScopeLock lock(_locker); - for (auto i = _registry.Begin(); i.IsNotEnd(); ++i) { if (i->Value.Info.TypeName == typeName) diff --git a/Source/Engine/Content/Cache/AssetsCache.h b/Source/Engine/Content/Cache/AssetsCache.h index cee2e0e8f..6364e09d2 100644 --- a/Source/Engine/Content/Cache/AssetsCache.h +++ b/Source/Engine/Content/Cache/AssetsCache.h @@ -173,6 +173,12 @@ public: return FindAsset(id, info); } + /// + /// Gets the asset ids. + /// + /// The result array. + void GetAll(Array& result) const; + /// /// Gets the asset ids that match the given typename. /// diff --git a/Source/Engine/Content/Content.cpp b/Source/Engine/Content/Content.cpp index abe40e285..3f5de3a0a 100644 --- a/Source/Engine/Content/Content.cpp +++ b/Source/Engine/Content/Content.cpp @@ -322,6 +322,13 @@ bool Content::GetAssetInfo(const StringView& path, AssetInfo& info) #endif } +Array Content::GetAllAssets() +{ + Array result; + Cache.GetAll(result); + return result; +} + Array Content::GetAllAssetsByType(const MClass* type) { Array result; diff --git a/Source/Engine/Content/Content.h b/Source/Engine/Content/Content.h index c8e3cad90..d0a277de8 100644 --- a/Source/Engine/Content/Content.h +++ b/Source/Engine/Content/Content.h @@ -73,6 +73,12 @@ public: /// True if found any asset, otherwise false. API_FUNCTION() static bool GetAssetInfo(const StringView& path, API_PARAM(Out) AssetInfo& info); + /// + /// Finds all the asset IDs. Uses asset registry. + /// + /// The list of all asset IDs. + API_FUNCTION() static Array GetAllAssets(); + /// /// Finds all the asset IDs by type (exact type, without inheritance checks). Uses asset registry. ///