The asset registry can be used to query and get events regarding assets in the project. It works both in editor and shipping. Use IAssetRegistry::Get()
to access it.
Note: While you can query the asset registry for UBlueprint classes like blueprint-based actors, the asset registry does not return any C++ based actors.
IAssetRegistry delegates
OnAssetsUpdated
runs when assets are saved and changed in some way. It does not run on add, delete, rename etc.OnAssetAdded
, runs on asset added and also asset renamed.- Important: Runs for every asset during the initial asset scan. If you want to use this, add the delegate only after
OnFilesLoaded
has triggered unless you have some reason to do so earlier. - Gotchas: If you use World Partition or One File Per Actor, this delegate runs whenever actors are placed into the world. Depending on what you’re doing you may need to take this into account.
- Important: Runs for every asset during the initial asset scan. If you want to use this, add the delegate only after
OnAssetRemoved
runs on asset removed, and also asset renamed. Probably also runs if you delete actors from the world with world partition or one file per actor enabled.OnFilesLoaded
runs on editor startup when the initial asset scan has finished. You can useIsLoadingAssets()
to check whether this has fired.
Assets in One File Per Actor
For Asset Added or other delegates which trigger for One File Per Actor assets, it seems you can detect it like so:
const FAssetData& AssetData = /* something */;
if(!AssetData.GetOptionalOuterPathName().IsNone())
{
//This asset is a One File Per Actor asset
return;
}
It would appear the Optional Outer Path Name is always empty, except in these types of circumstances. Some of the other fields also indicate it in various ways.