UAssetManager::ScanPathsForPrimaryAssets
#include "Engine/AssetManager.h"
Access: public
Specifiers: virtual
Description
Scans a list of file system paths and registers any matching assets of the given type into the primary asset directory. In the editor this reads asset data off disk; in cooked builds it reads from the asset registry cache.
Caveats & Gotchas
- • In cooked builds this reads from the asset registry cache rather than scanning disk, so newly added files won't be found unless they were present when the registry was built.
- • Assets that don't derive from BaseClass are silently skipped rather than logged as errors — a mismatched BaseClass is a common cause of 'my asset didn't show up' bugs.
- • Wrap several calls in PushBulkScanning()/PopBulkScanning() if you're scanning multiple types at once; scanning one at a time is noticeably slower in large projects.
Signature
virtual int32 ScanPathsForPrimaryAssets(FPrimaryAssetType PrimaryAssetType, const TArray<FString>& Paths, UClass* BaseClass, bool bHasBlueprintClasses, bool bIsEditorOnly = false, bool bForceSynchronousScan = true); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| PrimaryAssetType | FPrimaryAssetType | Type to assign to any matching assets found. | — |
| Paths | const TArray<FString>& | File system paths to scan. | — |
| BaseClass | UClass* | Base class assets must derive from to be included; others are skipped. | — |
| bHasBlueprintClasses | bool | True if the scanned assets are Blueprints subclassing BaseClass rather than base UObject assets. | — |
| bIsEditorOnly | bool | If true, only scans in editor builds and does not persist into the asset registry. | false |
| bForceSynchronousScan | bool | If true, scans the disk synchronously; otherwise waits for the asset registry scan to complete. | true |
Return Type
int32 Example
Scanning a folder for a primary asset type C++
TArray<FString> Paths = { TEXT("/Game/Items") };
int32 NumFound = UAssetManager::Get().ScanPathsForPrimaryAssets(
FPrimaryAssetType("Item"),
Paths,
UItemDefinition::StaticClass(),
/*bHasBlueprintClasses=*/ false); See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?