TSoftObjectPtr
Soft asset reference — stores a stable path, lazy-loads the asset through FSoftAssetResolver on LoadSynchronous() and caches a strong Ref<T>. Use in components / properties that reference an asset that may not be loaded yet (or may be unloaded and reloaded on demand). T must derive from RefCounted (our assets are intrusive-refcounted, not MObjects — asset lifetime stays with the Ref system, NOT the GC).
- Module
- Core
- Header
#include "Core/TObjectPtr.h"- Namespace
Mowo- Template
template<typename T>
Null returns mean: empty path, no resolver installed for T (asset module not initialised — headless tools), or the load failed.
Constructors
| Signature | Name | Description |
|---|---|---|
TSoftObjectPtr() = default | TSoftObjectPtr | |
explicit TSoftObjectPtr(std::string assetPath) : m_path(std::move(assetPath)) | TSoftObjectPtr | |
explicit TSoftObjectPtr(FName assetId) : m_id(assetId) | TSoftObjectPtr | |
explicit TSoftObjectPtr(const FSoftObjectPath& path) : m_path(path.AssetPath) | TSoftObjectPtr |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | IsNull | |
T* | Resolve | Cached strong reference if already resolved, nullptr otherwise. |
T* | LoadSynchronous | Synchronous resolve — loads through the installed resolver on first call, caches the strong reference. |
void | LoadAsync | Async resolve. |
void | Prime | Store an externally-loaded strong reference as this pointer's cache — the LoadAsync completion path when the holder survives. |
FName | GetAssetId | |
const std::string& | GetAssetPath | |
FSoftObjectPath | ToSoftObjectPath | What a reflected property stores: hold an FSoftObjectPath field and build the pointer from it where the asset is loaded. |
void | Reset | Drop the path AND the cached reference. |
void | SetPath | Point at a new asset — clears the cache so the next LoadSynchronous() loads the new path. |
Function details
TSoftObjectPtr
TSoftObjectPtr() = defaultTSoftObjectPtr
explicit TSoftObjectPtr(std::string assetPath) : m_path(std::move(assetPath))TSoftObjectPtr
explicit TSoftObjectPtr(FName assetId) : m_id(assetId)TSoftObjectPtr
explicit TSoftObjectPtr(const FSoftObjectPath& path) : m_path(path.AssetPath)IsNull
bool IsNull() const noexceptResolve
T* Resolve() const noexceptCached strong reference if already resolved, nullptr otherwise. Never triggers a load — pair with LoadSynchronous().
LoadSynchronous
T* LoadSynchronous()Synchronous resolve — loads through the installed resolver on first call, caches the strong reference.
LoadAsync
void LoadAsync(std::function<void(Ref<T>)> onLoaded)Async resolve. onLoaded receives the loaded Ref (null on failure) — on the main thread when the game-side async pipeline is installed, inline otherwise (already-cached, empty path, or sync-only resolver; same guarantees as LoadSynchronous in those cases). Deliberately does NOT write m_cached: the pointer may die before completion, so the callback owns the result — cache it back with Prime() if the holder is still alive.
Prime
void Prime(Ref<T> loaded)Store an externally-loaded strong reference as this pointer's cache — the LoadAsync completion path when the holder survives.
GetAssetId
FName GetAssetId() const noexceptGetAssetPath
const std::string& GetAssetPath() const noexceptToSoftObjectPath
FSoftObjectPath ToSoftObjectPath() constWhat a reflected property stores: hold an FSoftObjectPath field and build the pointer from it where the asset is loaded.
Reset
void Reset()Drop the path AND the cached reference.
SetPath
void SetPath(std::string path)Point at a new asset — clears the cache so the next LoadSynchronous() loads the new path.