which works fine but I want to change the text dynamically at runtime.
I can see in the UTextBlock doc that there is a member “TextDelegate” but it’s not clear to me how exactly the code should look like.
Can you guys give me an example please?
Thanks!
Argument where you got “this” is a object on which function will be called, and “this” means object which function you coding in belongs to.
Now, delegates can expect different functions, currently API reference very lacking on this info, so best way to figure out what function to use is by searching delegate type (in this case FGetText) in UE4 github and usally delegate decleration will be in one of results as delegates are usally declered at begining of source files, they look like this:
In this case you need to make function without any arguments (not OneParam or somethign like that in name) and return FText value (has RetVal in name and FText in begining is type of return). If you have MULTICAST in name it means it’s multiucast delegate and it can bind more then 1 function and you use AddDynamic, if it missing like in this case it a single cast delegate and it can have only one function binded, if you bind again function will be replaced and you use BindDynamic insted. Obviously single-cast delegate is needed to set up return value delegate.
Thanks, this worked.
Can you clarify why I should use BindDynamic() if this is not a dynamic delegate? Also what is the difference between dynamic and regular delegates?
I don’t know how it was before, but just in case I want to draw your attention to the fact that in version 4.25, brackets are not needed.
label->TextDelegate.BindDynamic(this, &USomeFancyClass::SomeFunction);