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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
CHECK_RETURN(type, nullptr);
|
||||
@@ -430,11 +449,6 @@ Asset* Content::LoadAsync(const StringView& path, const ScriptingTypeHandle& typ
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32 Content::GetAssetCount()
|
||||
{
|
||||
return Assets.Count();
|
||||
}
|
||||
|
||||
Array<Asset*> Content::GetAssets()
|
||||
{
|
||||
Array<Asset*> assets;
|
||||
|
||||
@@ -12,6 +12,20 @@ class FlaxFile;
|
||||
class IAssetFactory;
|
||||
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>
|
||||
/// Loads and manages assets.
|
||||
/// </summary>
|
||||
@@ -92,10 +106,9 @@ public:
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets amount of the assets (in memory).
|
||||
/// Gets content statistics.
|
||||
/// </summary>
|
||||
/// <returns>Amount of assets in the assets.</returns>
|
||||
API_PROPERTY() static int32 GetAssetCount();
|
||||
API_PROPERTY() static ContentStats GetStats();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the assets (loaded or during load).
|
||||
|
||||
Reference in New Issue
Block a user