UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TAttribute< ObjectType > Class Template Reference

#include <Attribute.h>

Public Member Functions

 DECLARE_DELEGATE_RetVal (ObjectType, FGetter)
 
 TAttribute ()
 
template<typename OtherType >
 TAttribute (const OtherType &InInitialValue)
 
 TAttribute (ObjectType &&InInitialValue)
 
template<class SourceType >
 TAttribute (TSharedRef< SourceType > InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
 
template<class SourceType >
 TAttribute (SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType > InMethodPtr)
 
template<typename OtherType >
void Set (const OtherType &InNewValue)
 
void Set (ObjectType &&InNewValue)
 
bool IsSet () const
 
const ObjectType & Get () const
 
const ObjectType & Get (const ObjectType &DefaultValue) const
 
void Bind (const FGetter &InGetter)
 
void Bind (FGetter &&InGetter)
 
template<typename... VarTypes>
void BindStatic (TIdentity_T< typename FGetter::template TFuncPtr< std::decay_t< VarTypes >... > > InFuncPtr, VarTypes &&... Vars)
 
template<class SourceType , typename... VarTypes>
void BindRaw (SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType, std::decay_t< VarTypes >... > InMethodPtr, VarTypes &&... Vars)
 
template<class SourceType , typename... VarTypes>
void Bind (TSharedRef< SourceType > InUserObject, typename FGetter::template TConstMethodPtr< SourceType, std::decay_t< VarTypes >... > InMethodPtr, VarTypes &&... Vars)
 
template<class SourceType , typename... VarTypes>
void Bind (SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType, std::decay_t< VarTypes >... > InMethodPtr, VarTypes &&... Vars)
 
template<class SourceType , typename... VarTypes>
void BindUObject (SourceType *InUserObject, typename FGetter::template TConstMethodPtr< SourceType, std::decay_t< VarTypes >... > InMethodPtr, VarTypes &&... Vars)
 
template<class SourceType >
void BindUFunction (SourceType *InUserObject, const FName &InFunctionName)
 
template<typename LambdaType , typename... PayloadTypes>
void BindLambda (LambdaType &&InCallable, PayloadTypes &&... InputPayload)
 
template<typename UserClass , ESPMode Mode, typename LambdaType , typename... PayloadTypes>
void BindSPLambda (const TSharedRef< UserClass, Mode > &InUserObjectRef, LambdaType &&InCallable, PayloadTypes &&... InputPayload)
 
template<typename UserClass , typename LambdaType , typename... PayloadTypes>
void BindSPLambda (const UserClass *InUserObject, LambdaType &&InCallable, PayloadTypes &&... InputPayload)
 
template<typename UserClass , typename LambdaType , typename... PayloadTypes>
void BindWeakLambda (UserClass *InUserObject, LambdaType &&InCallable, PayloadTypes &&... InputPayload)
 
bool IsBound () const
 
const FGetter & GetBinding () const
 
TVariant< ObjectType, FGetter > Steal ()
 
bool IdenticalTo (const TAttribute &InOther) const
 

Static Public Member Functions

static TAttribute Create (const FGetter &InGetter)
 
static TAttribute Create (FGetter &&InGetter)
 
template<typename FuncPtrType , typename... VarTypes>
static TAttribute CreateStatic (FuncPtrType &&InFuncPtr, VarTypes... Vars)
 
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute CreateRaw (const SourceType *InObject, ObjectType(SourceTypeOrBase::*InMethod)(PayloadTypes...) const, typename TDecay< PayloadTypes >::Type... InputPayload)
 
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute CreateSP (const SourceType *InObject, ObjectType(SourceTypeOrBase::*InMethod)(PayloadTypes...) const, typename TDecay< PayloadTypes >::Type... InputPayload)
 
template<typename LambdaType , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute CreateLambda (LambdaType &&InCallable, PayloadTypes &&... InputPayload)
 
template<typename UserClass , ESPMode Mode, typename LambdaType , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute CreateSPLambda (const TSharedRef< UserClass, Mode > &InUserObjectRef, LambdaType &&InCallable, PayloadTypes &&... InputPayload)
 
template<typename UserClass , typename LambdaType , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute CreateSPLambda (UserClass *InUserObject, LambdaType &&InCallable, PayloadTypes &&... InputPayload)
 
template<typename UserClass , typename LambdaType , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute CreateWeakLambda (UserClass *InUserObject, LambdaType &&InCallable, PayloadTypes &&... InputPayload)
 
template<class SourceType >
static TAttribute< ObjectType > Create (SourceType *InUserObject, const FName &InFunctionName)
 
static UE_FORCEINLINE_HINT TAttribute< ObjectType > Create (TFunction< ObjectType(void)> &&InLambda)
 

Friends

template<class OtherType >
class TAttribute
 

Detailed Description

template<typename ObjectType>
class TAttribute< ObjectType >

Attribute object

Examples
/work/Engine/Source/Runtime/UMG/Public/Components/Widget.h.

Constructor & Destructor Documentation

◆ TAttribute() [1/5]

template<typename ObjectType >
TAttribute< ObjectType >::TAttribute ( )
inline

Default constructor.

◆ TAttribute() [2/5]

template<typename ObjectType >
template<typename OtherType >
TAttribute< ObjectType >::TAttribute ( const OtherType InInitialValue)
inline

Construct implicitly from an initial value

Parameters
InInitialValueThe value for this attribute

◆ TAttribute() [3/5]

template<typename ObjectType >
TAttribute< ObjectType >::TAttribute ( ObjectType &&  InInitialValue)
inline

Construct implicitly from moving an initial value

Parameters
InInitialValue

◆ TAttribute() [4/5]

template<typename ObjectType >
template<class SourceType >
TAttribute< ObjectType >::TAttribute ( TSharedRef< SourceType >  InUserObject,
typename FGetter::template TConstMethodPtr< SourceType >  InMethodPtr 
)
inline

Constructs by binding an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectShared Pointer to the instance of the class that contains the member function you want to bind. The attribute will only retain a weak pointer to this class.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

◆ TAttribute() [5/5]

template<typename ObjectType >
template<class SourceType >
TAttribute< ObjectType >::TAttribute ( SourceType *  InUserObject,
typename FGetter::template TConstMethodPtr< SourceType >  InMethodPtr 
)
inline

Constructs by binding an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectShared Pointer to the instance of the class that contains the member function you want to bind. The attribute will only retain a weak pointer to this class.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

Member Function Documentation

◆ Bind() [1/4]

template<typename ObjectType >
void TAttribute< ObjectType >::Bind ( const FGetter &  InGetter)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InGetterThe delegate object with your function binding

◆ Bind() [2/4]

template<typename ObjectType >
void TAttribute< ObjectType >::Bind ( FGetter &&  InGetter)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InGetterThe delegate object with your function binding

◆ Bind() [3/4]

template<typename ObjectType >
template<class SourceType , typename... VarTypes>
void TAttribute< ObjectType >::Bind ( SourceType *  InUserObject,
typename FGetter::template TConstMethodPtr< SourceType, std::decay_t< VarTypes >... >  InMethodPtr,
VarTypes &&...  Vars 
)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectShared Pointer to the instance of the class that contains the member function you want to bind. The attribute will only retain a weak pointer to this class.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

◆ Bind() [4/4]

template<typename ObjectType >
template<class SourceType , typename... VarTypes>
void TAttribute< ObjectType >::Bind ( TSharedRef< SourceType >  InUserObject,
typename FGetter::template TConstMethodPtr< SourceType, std::decay_t< VarTypes >... >  InMethodPtr,
VarTypes &&...  Vars 
)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectShared Pointer to the instance of the class that contains the member function you want to bind. The attribute will only retain a weak pointer to this class.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

◆ BindLambda()

template<typename ObjectType >
template<typename LambdaType , typename... PayloadTypes>
void TAttribute< ObjectType >::BindLambda ( LambdaType &&  InCallable,
PayloadTypes &&...  InputPayload 
)
inline

Static: Binds a C++ lambda delegate technically this works for any functor types, but lambdas are the primary use case

◆ BindRaw()

template<typename ObjectType >
template<class SourceType , typename... VarTypes>
void TAttribute< ObjectType >::BindRaw ( SourceType *  InUserObject,
typename FGetter::template TConstMethodPtr< SourceType, std::decay_t< VarTypes >... >  InMethodPtr,
VarTypes &&...  Vars 
)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectInstance of the class that contains the member function you want to bind.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

◆ BindSPLambda() [1/2]

template<typename ObjectType >
template<typename UserClass , ESPMode Mode, typename LambdaType , typename... PayloadTypes>
void TAttribute< ObjectType >::BindSPLambda ( const TSharedRef< UserClass, Mode > &  InUserObjectRef,
LambdaType &&  InCallable,
PayloadTypes &&...  InputPayload 
)
inline

Static: Binds a weak shared pointer C++ lambda delegate technically this works for any functor types, but lambdas are the primary use case

◆ BindSPLambda() [2/2]

template<typename ObjectType >
template<typename UserClass , typename LambdaType , typename... PayloadTypes>
void TAttribute< ObjectType >::BindSPLambda ( const UserClass *  InUserObject,
LambdaType &&  InCallable,
PayloadTypes &&...  InputPayload 
)
inline

◆ BindStatic()

template<typename ObjectType >
template<typename... VarTypes>
void TAttribute< ObjectType >::BindStatic ( TIdentity_T< typename FGetter::template TFuncPtr< std::decay_t< VarTypes >... > >  InFuncPtr,
VarTypes &&...  Vars 
)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InFuncPtrFunction to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

◆ BindUFunction()

template<typename ObjectType >
template<class SourceType >
void TAttribute< ObjectType >::BindUFunction ( SourceType *  InUserObject,
const FName InFunctionName 
)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectInstance of the class that contains the member function you want to bind.
InFunctionNameMember function name to bind.

◆ BindUObject()

template<typename ObjectType >
template<class SourceType , typename... VarTypes>
void TAttribute< ObjectType >::BindUObject ( SourceType *  InUserObject,
typename FGetter::template TConstMethodPtr< SourceType, std::decay_t< VarTypes >... >  InMethodPtr,
VarTypes &&...  Vars 
)
inline

Binds an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectInstance of the class that contains the member function you want to bind.
InMethodPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

◆ BindWeakLambda()

template<typename ObjectType >
template<typename UserClass , typename LambdaType , typename... PayloadTypes>
void TAttribute< ObjectType >::BindWeakLambda ( UserClass *  InUserObject,
LambdaType &&  InCallable,
PayloadTypes &&...  InputPayload 
)
inline

Static: Binds a weak object C++ lambda delegate technically this works for any functor types, but lambdas are the primary use case

◆ Create() [1/4]

template<typename ObjectType >
static TAttribute TAttribute< ObjectType >::Create ( const FGetter &  InGetter)
inlinestatic

Static: Creates an attribute that's pre-bound to the specified 'getter' delegate

Parameters
InGetterDelegate to bind

◆ Create() [2/4]

template<typename ObjectType >
static TAttribute TAttribute< ObjectType >::Create ( FGetter &&  InGetter)
inlinestatic

Static: Creates an attribute that's pre-bound to the specified 'getter' delegate

Parameters
InGetterDelegate to bind

◆ Create() [3/4]

template<typename ObjectType >
template<class SourceType >
static TAttribute< ObjectType > TAttribute< ObjectType >::Create ( SourceType *  InUserObject,
const FName InFunctionName 
)
inlinestatic

Creates an attribute by binding an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InUserObjectInstance of the class that contains the member function you want to bind.
InFunctionNameMember function name to bind.

◆ Create() [4/4]

template<typename ObjectType >
static UE_FORCEINLINE_HINT TAttribute< ObjectType > TAttribute< ObjectType >::Create ( TFunction< ObjectType(void)> &&  InLambda)
inlinestatic

◆ CreateLambda()

template<typename ObjectType >
template<typename LambdaType , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute TAttribute< ObjectType >::CreateLambda ( LambdaType &&  InCallable,
PayloadTypes &&...  InputPayload 
)
inlinestatic

Helper function for creating TAttributes from a lambda TAttribute<float> FloatAttribute = TAttribute<float>::CreateLambda([]{ return 10.f; });

◆ CreateRaw()

template<typename ObjectType >
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute TAttribute< ObjectType >::CreateRaw ( const SourceType *  InObject,
ObjectType(SourceTypeOrBase::*)(PayloadTypes...) const  InMethod,
typename TDecay< PayloadTypes >::Type...  InputPayload 
)
inlinestatic

Helper function for creating TAttributes from a const member function pointer, accessed through a raw pointer

◆ CreateSP()

template<typename ObjectType >
template<typename SourceType , typename SourceTypeOrBase , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute TAttribute< ObjectType >::CreateSP ( const SourceType *  InObject,
ObjectType(SourceTypeOrBase::*)(PayloadTypes...) const  InMethod,
typename TDecay< PayloadTypes >::Type...  InputPayload 
)
inlinestatic

Helper function for creating TAttributes from a const member function pointer, accessed through a weak pointer to the shared object

◆ CreateSPLambda() [1/2]

template<typename ObjectType >
template<typename UserClass , ESPMode Mode, typename LambdaType , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute TAttribute< ObjectType >::CreateSPLambda ( const TSharedRef< UserClass, Mode > &  InUserObjectRef,
LambdaType &&  InCallable,
PayloadTypes &&...  InputPayload 
)
inlinestatic

Helper function for creating TAttributes from a weak shared pointer C++ lambda delegate

◆ CreateSPLambda() [2/2]

template<typename ObjectType >
template<typename UserClass , typename LambdaType , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute TAttribute< ObjectType >::CreateSPLambda ( UserClass *  InUserObject,
LambdaType &&  InCallable,
PayloadTypes &&...  InputPayload 
)
inlinestatic

◆ CreateStatic()

template<typename ObjectType >
template<typename FuncPtrType , typename... VarTypes>
static TAttribute TAttribute< ObjectType >::CreateStatic ( FuncPtrType &&  InFuncPtr,
VarTypes...  Vars 
)
inlinestatic

Creates an attribute by binding an arbitrary function that will be called to generate this attribute's value on demand. After binding, the attribute will no longer have a value that can be accessed directly, and instead the bound function will always be called to generate the value.

Parameters
InFuncPtrMember function to bind. The function's structure (return value, arguments, etc) must match IBoundAttributeDelegate's definition.

◆ CreateWeakLambda()

template<typename ObjectType >
template<typename UserClass , typename LambdaType , typename... PayloadTypes>
static UE_FORCEINLINE_HINT TAttribute TAttribute< ObjectType >::CreateWeakLambda ( UserClass *  InUserObject,
LambdaType &&  InCallable,
PayloadTypes &&...  InputPayload 
)
inlinestatic

Helper function for creating TAttributes from a weak object pointer C++ lambda delegate

◆ DECLARE_DELEGATE_RetVal()

template<typename ObjectType >
TAttribute< ObjectType >::DECLARE_DELEGATE_RetVal ( ObjectType  ,
FGetter   
)

Attribute 'getter' delegate

ObjectType GetValue() const

Returns
The attribute's value

◆ Get() [1/2]

template<typename ObjectType >
const ObjectType & TAttribute< ObjectType >::Get ( ) const
inline

Gets the attribute's current value. Assumes that the attribute is set.

Returns
The attribute's value

◆ Get() [2/2]

template<typename ObjectType >
const ObjectType & TAttribute< ObjectType >::Get ( const ObjectType &  DefaultValue) const
inline

Gets the attribute's current value. The attribute may not be set, in which case use the default value provided. Shorthand for the boilerplate code: MyAttribute.IsSet() ? MyAttribute.Get() : DefaultValue

◆ GetBinding()

template<typename ObjectType >
const FGetter & TAttribute< ObjectType >::GetBinding ( ) const
inline

Gets the attribute's 'getter' which can be bound or unbound

Returns
The attribute's FGetter.

◆ IdenticalTo()

template<typename ObjectType >
bool TAttribute< ObjectType >::IdenticalTo ( const TAttribute< ObjectType > &  InOther) const
inline

Is this attribute identical to another TAttribute.

Parameters
InOtherThe other attribute to compare with.
Returns
true if the attributes are identical, false otherwise.

◆ IsBound()

template<typename ObjectType >
bool TAttribute< ObjectType >::IsBound ( ) const
inline

Checks to see if this attribute has a 'getter' function bound

Returns
True if attribute is bound to a getter function

◆ IsSet()

template<typename ObjectType >
bool TAttribute< ObjectType >::IsSet ( ) const
inline

Was this TAttribute ever assigned?

◆ Set() [1/2]

template<typename ObjectType >
template<typename OtherType >
void TAttribute< ObjectType >::Set ( const OtherType InNewValue)
inline

Sets the attribute's value

Parameters
InNewValueThe value to set the attribute to

◆ Set() [2/2]

template<typename ObjectType >
void TAttribute< ObjectType >::Set ( ObjectType &&  InNewValue)
inline

Sets the attribute's value

Parameters
InNewValueThe value to set the attribute to

◆ Steal()

template<typename ObjectType >
TVariant< ObjectType, FGetter > TAttribute< ObjectType >::Steal ( )
inline

Move the attribute's 'getter' or the attribute's Value and reset the attribute. The attribute needs to be set.

Returns
The attribute's FGetter or Value

Friends And Related Symbol Documentation

◆ TAttribute

template<typename ObjectType >
template<class OtherType >
friend class TAttribute
friend

The documentation for this class was generated from the following file: