Add Content.Stats for assets statistics (replaces Content.AssetCount)
This commit is contained in:
@@ -360,6 +360,25 @@ String Content::CreateTemporaryAssetPath()
|
|||||||
return Globals::TemporaryFolder / (Guid::New().ToString(Guid::FormatType::N) + ASSET_FILES_EXTENSION_WITH_DOT);
|
return Globals::TemporaryFolder / (Guid::New().ToString(Guid::FormatType::N) + ASSET_FILES_EXTENSION_WITH_DOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContentStats Content::GetStats()
|
||||||
|
{
|
||||||
|
ContentStats stats;
|
||||||
|
AssetsLocker.Lock();
|
||||||
|
stats.AssetsCount = Assets.Count();
|
||||||
|
for (auto& e : Assets)
|
||||||
|
{
|
||||||
|
if (e.Value->IsLoaded())
|
||||||
|
stats.LoadedAssetsCount++;
|
||||||
|
else if (e.Value->LastLoadFailed())
|
||||||
|
stats.LoadingAssetsCount++;
|
||||||
|
if (e.Value->IsVirtual())
|
||||||
|
stats.VirtualAssetsCount++;
|
||||||
|
}
|
||||||
|
stats.LoadingAssetsCount = stats.AssetsCount - stats.LoadingAssetsCount - stats.LoadedAssetsCount;
|
||||||
|
AssetsLocker.Unlock();
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
Asset* Content::LoadAsyncInternal(const StringView& internalPath, MClass* type)
|
Asset* Content::LoadAsyncInternal(const StringView& internalPath, MClass* type)
|
||||||
{
|
{
|
||||||
CHECK_RETURN(type, nullptr);
|
CHECK_RETURN(type, nullptr);
|
||||||
@@ -430,11 +449,6 @@ Asset* Content::LoadAsync(const StringView& path, const ScriptingTypeHandle& typ
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 Content::GetAssetCount()
|
|
||||||
{
|
|
||||||
return Assets.Count();
|
|
||||||
}
|
|
||||||
|
|
||||||
Array<Asset*> Content::GetAssets()
|
Array<Asset*> Content::GetAssets()
|
||||||
{
|
{
|
||||||
Array<Asset*> assets;
|
Array<Asset*> assets;
|
||||||
|
|||||||
@@ -12,6 +12,20 @@ class FlaxFile;
|
|||||||
class IAssetFactory;
|
class IAssetFactory;
|
||||||
class AssetsCache;
|
class AssetsCache;
|
||||||
|
|
||||||
|
// Content and assets statistics container.
|
||||||
|
API_STRUCT() struct FLAXENGINE_API ContentStats
|
||||||
|
{
|
||||||
|
DECLARE_SCRIPTING_TYPE_MINIMAL(ContentStats);
|
||||||
|
// Amount of asset objects in memory.
|
||||||
|
API_FIELD() int32 AssetsCount = 0;
|
||||||
|
// Amount of loaded assets.
|
||||||
|
API_FIELD() int32 LoadedAssetsCount = 0;
|
||||||
|
// Amount of loading assets.
|
||||||
|
API_FIELD() int32 LoadingAssetsCount = 0;
|
||||||
|
// Amount of virtual assets (don't have representation in file).
|
||||||
|
API_FIELD() int32 VirtualAssetsCount = 0;
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads and manages assets.
|
/// Loads and manages assets.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -92,10 +106,9 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets amount of the assets (in memory).
|
/// Gets content statistics.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Amount of assets in the assets.</returns>
|
API_PROPERTY() static ContentStats GetStats();
|
||||||
API_PROPERTY() static int32 GetAssetCount();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the assets (loaded or during load).
|
/// Gets the assets (loaded or during load).
|
||||||
|
|||||||
Reference in New Issue
Block a user