TObjectPtr

[TObjectPtr](API\Runtime\Core\Delegates\TObjectPtr) is a type of pointer to a [UObject](API\Runtime\CoreUObject\UObject\UObject) that is meant to function as a drop-in replacement for raw pointer member properties.

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Delegates/DelegateSignatureImpl.inl

Include

#include "Delegates/DelegateSignatureImpl.inl"

Syntax

template<typename T>
struct TObjectPtr

Remarks

TObjectPtr is a type of pointer to a UObject that is meant to function as a drop-in replacement for raw pointer member properties. It is size equivalent to a 64-bit pointer and supports access tracking and optional lazy load behavior in editor builds. It stores either the address to the referenced object or (in editor builds) an index in the object handle table that describes a referenced object that hasn't been loaded yet. It is serialized identically to a raw pointer to a UObject. When resolved, its participation in garbage collection is identical to a raw pointer to a UObject.

This is useful for automatic replacement of raw pointers to support advanced cook-time dependency tracking and editor-time lazy load use cases. See UnrealObjectPtrTool for tooling to automatically replace raw pointer members with FObjectPtr/TObjectPtr members instead.

Variables

Name Description

Public variable

T *

 

DebugPtr

DebugPtr allows for easier dereferencing of a resolved TObjectPtr in watch windows of debuggers.

Public variable

FObjectPtr

 

ObjectPtr

Constructors

Name Description

Public function

TObjectPtr()

Public function

TObjectPtr

(
    TPrivateObjectPtr< T >&& PrivatePt...
)

Public function

TObjectPtr

(
    TObjectPtr< T >&& Other
)

Public function

TObjectPtr

(
    const TObjectPtr< T >& Other
)

Public function

TObjectPtr

(
    ENoInit
)

Public function

TObjectPtr

(
    TYPE_OF_NULLPTR
)

Public function

TObjectPtr

(
    FObjectPtr ObjPtr
)

Public function

TObjectPtr

(
    const TObjectPtr< U >& Other
)

Public function

TObjectPtr

(
    U&& Object
)

Public function

TObjectPtr

(
    T& Object
)

Functions

Name Description

Public function Const

T *

 

Get()

: OBJPTR: There is a risk that the FObjectPtr is storing a reference to the wrong type.

Public function Const

UClass *

 

GetClass()

Public function Const

FName

 

GetFName()

Public function Const

FString

 

GetFullName

(
    EObjectFullNameFlags Flags
)

Public function Const

FObjectHandl...

 

GetHandle()

Public function Const

FString

 

GetName()

Public function Const

TObjectPtr< ...

 

GetOuter()

Public function Const

TObjectPtr< ...

 

GetPackage()

Public function Const

FString

 

GetPath()

Public function Const

FString

 

GetPathName()

Public function Const

uint32

 

GetPtrTypeHash()

Public function Const

bool

 

IsA

(
    const UClass* SomeBase
)

Public function Const

bool

 

IsA()

Public function Const

bool

 

IsResolved()

Public function

void

 

SerializePtrStructured

(
    FStructuredArchiveSlot Slot
)

Operators

Name Description

Public function Const

 

operator bool()

Public function Const

 

operator T *()

Public function

 

operator T *&()

Public function Const

 

operator U *()

Public function Const

 

operator UPTRINT()

Public function Const

bool

 

operator!()

Public function Const

bool

 

operator!=

(
    const TObjectPtr< U >& Other
)

Public function Const

bool

 

operator!=

(
    TYPE_OF_NULLPTR
)

Public function Const

bool

 

operator!=

(
    U&& Other
)

Public function Const

T &

 

operator*()

Public function

TObjectPtr< ...

 

operator=

(
    TYPE_OF_NULLPTR
)

Public function

TObjectPtr< ...

 

operator=

(
    U&& Object
)

Public function

TObjectPtr< ...

 

operator=

(
    const TObjectPtr< U >& Other
)

Public function

TObjectPtr< ...

 

operator=

(
    TPrivateObjectPtr< T >&& PrivatePt...
)

Public function

TObjectPtr< ...

 

operator=

(
    const TObjectPtr< T >&
)

Public function

TObjectPtr< ...

 

operator=

(
    TObjectPtr< T >&&
)

Public function Const

bool

 

operator==

(
    const TObjectPtr< U >& Other
)

Equality/Inequality comparisons against other TObjectPtr.

Public function Const

bool

 

operator==

(
    TYPE_OF_NULLPTR
)

Equality/Inequality comparisons against nullptr.

Public function Const

bool

 

operator==

(
    U&& Other
)

Equality/Inequality comparisons against another type that can be implicitly converted to the pointer type kept in a TObjectPtr.

Public function Const

T *

 

operator->()

Typedefs

Name

Description

ElementType

TObjectPtr should only be used on types T that are EITHER:

Deprecated Functions

Name Description

Public function Const

bool

 

IsNull()

IsNull is deprecated, please use operator bool instead. if (!MyObjectPtr) { ... }

Public function Const

bool

 

IsNullNoResolve()

IsNullNoResolve is deprecated, please use operator bool instead. if (!MyObjectPtr) { ... }

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel