Navigation
Unreal Engine C++ API Reference > Runtime > CoreUObject > UObject
References
Module | CoreUObject |
Header | /Engine/Source/Runtime/CoreUObject/Public/UObject/WeakObjectPtr.h |
Include | #include "UObject/WeakObjectPtr.h" |
Syntax
struct FWeakObjectPtr
Remarks
FWeakObjectPtr is a weak pointer to a UObject. It can return nullptr later if the object is garbage collected. It has no impact on if the object is garbage collected or not. It can't be directly used across a network.
Most often it is used when you explicitly do NOT want to prevent something from being garbage collected.
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
Null constructor | ||
![]() |
Construct from nullptr or something that can be implicitly converted to nullptr (eg: NULL) | ||
![]() |
FWeakObjectPtr
(
U&& Object |
Construct from an object pointer or something that can be implicitly converted to an object pointer | |
![]() |
FWeakObjectPtr
(
const FWeakObjectPtr& Other |
Construct from another weak pointer |
Functions
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
UObject * | Get
(
bool bEvenIfGarbage |
Dereference the weak pointer. |
![]() ![]() |
UObject * | Get () |
Dereference the weak pointer. This is an optimized version implying bEvenIfGarbage=false. |
![]() ![]() |
UObject * | Dereference the weak pointer even if it is marked as Garbage or Unreachable | |
![]() ![]() |
int32 | ||
![]() ![]() |
uint32 | GetTypeHash () |
Hash function. |
![]() ![]() |
bool | HasSameIndexAndSerialNumber
(
const FWeakObjectPtr& Other |
Returns true if two weak pointers were originally set to the same object, even if they are now stale |
![]() ![]() |
bool | Returns true if this pointer was explicitly assigned to null, was reset, or was never initialized. | |
![]() ![]() |
bool | IsStale
(
bool bIncludingGarbage, |
Slightly different than !IsValid(), returns true if this used to point to a UObject, but doesn't any more and has not been assigned or reset in the mean time. |
![]() ![]() |
bool | IsValid
(
bool bEvenIfGarbage, |
Test if this points to a live UObject This should be done only when needed as excess resolution of the underlying pointer can cause performance issues. |
![]() ![]() |
bool | IsValid () |
Test if this points to a live UObject. |
![]() ![]() |
TStrongObjectPtr< UObject > | Pin () |
Get a strong object ptr to the weak pointer. |
![]() ![]() |
TStrongObjectPtr< UObject > | Pin
(
bool bEvenIfGarbage |
Get a strong object ptr to the weak pointer. |
![]() ![]() |
TStrongObjectPtr< UObject > | Get a strong object ptr even if it is marked as Garbage or Unreachable | |
![]() |
void | Reset () |
Reset the weak pointer back to the null state |
![]() |
void | Weak object pointer serialization. |
Operators
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
This is explicitly not added to avoid resolving weak pointers too often - use Get() once in a function. | ||
![]() ![]() |
bool | operator!=
(
const FWeakObjectPtr& Other |
Compare weak pointers for inequality |
![]() |
void | Copy from an object pointer | |
![]() |
void | operator=
(
TObjectPtr< UObject > Object |
|
![]() |
FWeakObjectPtr & | operator=
(
const FWeakObjectPtr& Other |
Construct from another weak pointer |
![]() ![]() |
bool | operator==
(
const FWeakObjectPtr& Other |
Compare weak pointers for equality. |