RealDocs

FSoftObjectPath::SetPath

function CoreUObject Since 4.18
#include "UObject/SoftObjectPath.h"
Access: public

Description

Replaces the entire path (asset path and any sub-object path) of this FSoftObjectPath. Overloads accept FTopLevelAssetPath, FString, FWideStringView, FAnsiStringView, FUtf8StringView, and UObject pointer.

Caveats & Gotchas

  • Overloads that accept FWideString sub-paths are deprecated as of UE 5.6 (currently suppressed). Use the FUtf8String or FTopLevelAssetPath overloads to avoid a future breaking change.
  • Passing a UObject pointer encodes GetPathName() at the moment of the call. If the object is subsequently renamed or its package moved, the stored path becomes stale — FSoftObjectPath does not track live object renames.

Signature

COREUOBJECT_API void SetPath(const FTopLevelAssetPath& InAssetPath);

Parameters

Name Type Description Default
InAssetPath const FTopLevelAssetPath& The top-level asset path to assign, consisting of a package name and an asset name.

Return Type

void

Example

Point an existing soft reference at a different asset C++
FSoftObjectPath AssetRef;
AssetRef.SetPath(FTopLevelAssetPath(TEXT("/Game/Textures"), TEXT("T_Rock_D")));
UE_LOG(LogTemp, Log, TEXT("%s"), *AssetRef.ToString());
// Prints: /Game/Textures.T_Rock_D

Version History

Introduced in: 4.18

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.