Having One word in text a variable

Hey guys,
I have been working on a UMG text block. Basicly a short message which goes like:
“Hey there you have done something that work %integer% amount of money”
I am using blueprints and UMG only no code. How do I change that number, basicly how do u make the number within the text a variable but remain a normal text layout?
It can be done with 3 text boxes setting one to var but then you dont have a normal flowing text.

Maybe there’s a better way, but You could set the text in the Widget:

  • By Append String

  • By Join String Array

Magena-o-Pink node is toText node (it’s made automatically when plugging string into text input).

Thanks, that works perfectly!

Glad it worked for You! Good luck!

The correct way to do this in a way that is localisation aware is to use the “Format Text” node to inject your variable into a format string, which you’d then hook-up to your UI as S-ed suggested.

The format string would look like “Hey there you have done something that work {Var} amount of money”, and you’d hook up your integer to the “Var” pin (see Formatting User-Facing Text for more details).

Do not use strings for user facing text (except for player defined values, like their name) as they can’t be localised correctly, and will incur a FString → FText penalty each time they’re passed to the UI.

Thank you, that does sound better and ‘more correct’ in the long run. For our current prototype the solution above works but I will certainly mark down the link for future reference and implementation!

That’s nice. Wasn’t aware of it. I’ll advice that way next time.