FLimenSoftObjectPtr
Overview
FLimenSoftObjectPtr is a utility struct designed to manage soft object pointers (TSoftObjectPtr) with both asynchronous and synchronous loading capabilities. It provides methods to load objects asynchronously or synchronously, cast the loaded object to a specific type, and check if the pointer is valid or null.
Properties
Type | Name | Access | Description |
|---|---|---|---|
| SoftPtr | Protected | The soft object pointer that holds the reference to the UObject. |
| StrongPtr | Protected | A strong object pointer used for holding a hard reference to the loaded object. |
Functions
Return Type | Signature | Description |
|---|---|---|
void | LoadAsync() | Loads the soft object asynchronously using a default callback. |
template void LoadAsync(const TFunction<void(T*)>& Callback) | Loads the soft object asynchronously and calls the provided callback with the loaded object cast to type | |
template T* LoadSynchronous() | Loads the soft object synchronously and returns it cast to type | |
void LoadSynchronous() | Loads the soft object synchronously. | |
void ReleaseHardRef() | Releases the hard reference held by | |
template operator T() | Casts the loaded object to type | |
template T* Get() | Returns a pointer to the loaded object cast to type | |
bool IsValid() const | Checks if the strong pointer is valid (i.e., the object has been successfully loaded). | |
bool IsNull() const | Checks if the soft pointer is null. | |
TSoftObjectPtr SoftObjectPtr() const | Returns a copy of the soft object pointer. |
Usage & Implementation Notes
This struct uses
TSoftObjectPtrandTStrongObjectPtrto manage object references, allowing for asynchronous loading without blocking the main thread.The
LoadAsyncfunction can be used with or without a callback, providing flexibility in how the loaded object is handled once it becomes available.The
ReleaseHardRefmethod allows for manual management of the strong reference, which can be useful in scenarios where you need to ensure that the object remains valid for an extended period.