RealDocs

TSoftClassPtr

struct CoreUObject Since 4.18
#include "UObject/SoftObjectPtr.h"

Description

A soft reference to a UClass (Blueprint or C++) that stores the class path as a string rather than keeping the class loaded. Analogous to TSubclassOf but without holding a hard reference.

Signature

template<class TClass=UObject> class TSoftClassPtr

Caveats & Gotchas

  • The class is not loaded just because the pointer is set. You must call LoadSynchronous() or use async loading before using it.
  • Useful in data assets or configs that reference Blueprint classes without forcing them into memory at startup.
  • If the target Blueprint is deleted or renamed, this pointer becomes invalid.

Example

Lazy-load a Blueprint class for spawning C++
UPROPERTY(EditDefaultsOnly)
TSoftClassPtr<AMyCharacter> CharacterClass;

UClass* LoadedClass = CharacterClass.LoadSynchronous();
if (LoadedClass)
{
    GetWorld()->SpawnActor<AMyCharacter>(LoadedClass, SpawnTransform);
}

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.