UGantryAssetManager
Asset manager that records every load as a named, tagged scope in the Gantry load ledger.
Set it as the project's asset manager in DefaultEngine.ini:
[/Script/Engine.Engine]
AssetManagerClassName=/Script/GantryGauge.GantryAssetManager
Each tracked entry point opens a scope, attaches the load to it, and closes the scope when the load completes. The engine's own startup scan is recorded too.
In Blueprint
Use the Load Assets Tracked and Load Primary Assets Tracked nodes. They go through this asset manager.
In C++
Call UGantryAssetManager::RequestAsyncLoadTracked (static), or PreloadPrimaryAssetsTracked on UGantryAssetManager::Get(). Avoid LoadSynchronous and hard references for content a loading screen should see: those loads are not tracked.
To use an asset manager of your own, subclass this one and name the subclass in AssetManagerClassName instead.
- Inherits
UAssetManager
Properties
| Property | Type | Default | Description |
|---|---|---|---|
PinnedAssets | TSet<TObjectPtr<UObject> > | () | Assets pinned by GetAsset / GetSubclass. |
C++
Public C++ members that Blueprint does not see.
UGantryAssetManager
Default construction; the engine creates the one instance named in AssetManagerClassName.
StartInitialLoading
virtual void
Runs the engine's initial loading inside a Bootstrap scope named "Primary asset scan", so the scan shows up in the ledger.
FinishInitialLoading
virtual void
Finishes the engine's initial loading and logs that it has finished.
PostInitialAssetScan
virtual void
Runs the engine's post-scan step and logs that the primary asset scan is complete.
LoadSynchronousTracked
UObject *
Loads a single asset synchronously, recording it in the ledger and warning about it.
Every call is a frame hitch, so it logs a warning. The warning appears when UGantryGaugeSettings::bWarnOnBlockingLoads is on and the engine is past its initial load. The load is recorded as a background (not user-facing) Content scope, closed as Failed when nothing loads.
AssetPath:Asset to load. An invalid path returns null without recording anything.
Context:Who is asking, for the warning, e.g. the calling function. May be null.
Returns: The loaded object, or null if the path is invalid or the load failed.
PreloadPrimaryAssetsTracked
TSharedPtr< FStreamableHandle >
Async loads primary assets and their bundles inside a user-facing scope, and returns without waiting.
Goes through UAssetManager::LoadPrimaryAssets; the scope closes as Completed when the returned handle completes and as Cancelled if it is cancelled. When everything is already resident, the scope is settled and OnComplete fires before this returns. Game thread.
AssetIds:Primary assets to load.
LoadBundles:Bundles to load alongside them.
DebugName:What a loading bar should call this, e.g. "Environment".
ReasonTag:Scope kind, e.g. GantryGaugeTags::Load_Scope_Experience.
OnComplete:Fired on the game thread once everything has loaded, or immediately when nothing needed loading.
ParentScope:Optional parent scope, for nesting inside a larger operation.
OnCancelled:Fired on the game thread if the load is cancelled instead.
Returns: The streamable handle, or null if nothing needed loading.
AddPinnedAsset
void
Keeps an asset in memory for the lifetime of the asset manager.
Thread safe; null is ignored.
Get
static UGantryAssetManager &
Returns the engine's asset manager as a UGantryAssetManager.
A fatal error if AssetManagerClassName does not name this class or a subclass of it.
GetPtr
static UGantryAssetManager *
Returns the engine's asset manager if it is a UGantryAssetManager, otherwise null.
For code that must tolerate an unconfigured asset manager or run before the engine exists.
RequestAsyncLoadTracked
static TSharedPtr< FStreamableHandle >
Async loads a set of assets inside a named, tagged scope.
The scope closes as Completed when the handle completes and as Cancelled if it is cancelled. When every asset is already resident, the scope is recorded and closed and OnComplete fires before this returns; an empty TargetsToStream fires OnComplete at once and opens no scope. Game thread.
Static: it needs only the engine's streamable manager and Gantry's load ledger, so it works whatever the project's asset manager class is (a ledger that is switched off records nothing).
TargetsToStream:Assets to load.
DebugName:What a loading bar should call this, e.g. "Environment".
ReasonTag:Scope kind, e.g. GantryGaugeTags::Load_Scope_Content.
OnComplete:Fired on the game thread once the request has finished. Not fired on cancel. Finished does not mean every path resolved: check the objects.
ParentScope:Optional parent scope, for nesting inside a larger operation.
bUserFacing:Whether a loading bar should count this work.
OnCancelled:Fired on the game thread if the request is cancelled instead.
Returns: The streamable handle (already complete when everything was resident), or null for an empty request or when the engine answered without one.
GetAsset
AssetType *
Returns the asset a soft pointer names, loading it synchronously if it is not in memory, and optionally pinning it for the asset manager's lifetime.
The load goes through LoadSynchronousTracked, so it is recorded and warned about. Returns null for a null soft pointer or a failed load. Prefer RequestAsyncLoadTracked; this exists for the cases that genuinely cannot wait.
GetSubclass
TSubclassOf< AssetType >
As GetAsset, for soft class pointers: returns the class, loading and pinning it as asked.
DumpPinnedAssets
static void
Logs every pinned asset.
Backs the Gantry.DumpPinnedAssets console command.