I did it here and it worked:
- I used the TextDelegate property from the UTextBlock class.
- This property expect a FText as a return, so the function you bind must return this type and you have to make all conversions for that.
- My example below:
Initialization an pointer protection for the Text:
/* 18 Pointer protection PowerBarPercentText */
if (PowerBarPercentText)
{
PowerBarPercentText->SetText(FText::FromString(""));
PowerBarPercentText->TextDelegate.BindUFunction(this, "GetPowerBarPercentageString");
}
The function that was binded, returning the power percent as the content for the text
FText UIceBreakerUserWidgetInGame::GetPowerBarPercentageString()
{
if (MyClassThatHaveTheFuncion)
{
return FText::FromString(FString::SanitizeFloat(MyClassThatHaveTheFuncion->HitPowerPercent));
}
else
{
return FText::FromString("");
}
}