RealDocs

FSoftObjectPath::LoadAsync

function CoreUObject Since 5.0
#include "UObject/SoftObjectPath.h"
Access: public Specifiers: const

Description

Initiates an asynchronous load of the referenced asset and returns a request ID. The completion delegate fires on the game thread once the load succeeds or fails.

Caveats & Gotchas

  • The returned request ID can be passed to CancelAsyncLoading() to cancel an in-flight request, but cancellation is not guaranteed once the load is already underway.
  • For fine-grained control over callback timing, garbage-collection prevention, and priority management, prefer FStreamableManager::RequestAsyncLoad over this convenience wrapper.

Signature

COREUOBJECT_API int32 LoadAsync(FLoadSoftObjectPathAsyncDelegate InCompletionDelegate, FLoadAssetAsyncOptionalParams InOptionalParams = FLoadAssetAsyncOptionalParams()) const;

Parameters

Name Type Description Default
InCompletionDelegate FLoadSoftObjectPathAsyncDelegate Delegate called on the game thread when loading completes. Receives the FSoftObjectPath and the loaded UObject (null on failure).
InOptionalParams FLoadAssetAsyncOptionalParams Optional parameters controlling load priority, bundle names, and other async loading hints. FLoadAssetAsyncOptionalParams()

Return Type

int32

Example

Async load a weapon mesh on demand C++
UPROPERTY(EditAnywhere)
FSoftObjectPath WeaponMeshPath;

void AMyCharacter::RequestWeaponLoad()
{
    WeaponMeshPath.LoadAsync(
        FLoadSoftObjectPathAsyncDelegate::CreateLambda(
            [this](const FSoftObjectPath& Path, UObject* LoadedObj)
            {
                if (UStaticMesh* Mesh = Cast<UStaticMesh>(LoadedObj))
                {
                    WeaponMeshComponent->SetStaticMesh(Mesh);
                }
            })
    );
}

Version History

Introduced in: 5.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.