Set UObject Delegate for TAttribute<T>

By default, TAttribute<T> can create the following:

  • Lambda

  • Raw

  • SP

  • Static

But the UFunction and UObject delegates need extra bullshit.

Either, the TAttribute has to be pre-initialised:

TAttribute<T> AttributeDelegate = TAttribute<T>();
AttributeDelegate.BindUObject(this, &UMyObject::MyDelegate);

Or, it can be created inline by using the basic “Create” and then a “FGetter”:

TAttribute<T>::Create(TAttribute<T>::FGetter::CreateUObject(this, &UMyObject::MyDelegate))

Example from Osero Suite: Plugin Sync Tool using TAttribute<FSlateColor>:

SCB_Plugins->AddSlot()
[
  SNew(SButton)
  .Text(FText::FromString(PluginFolders[i]))
  .ButtonColorAndOpacity(TAttribute<FSlateColor>::Create(TAttribute<FSlateColor>::FGetter::CreateUObject(Settings, &UOS_PST_Settings::PluginToSyncColour, PluginFolders[i])))
  .OnClicked_UObject(Settings, &UOS_PST_Settings::ButtonClicked_PluginToSync, PluginFolders[i])
];

Last updated