Why is the Text Format Node Hardcoded?

Strange that the Format Text cannot be a variable. Both the variable and the format have the localization flags.

I’m curious to know why this is. I tried to use the variable text with brackets, but it was interpreted as a literal.

The only solution is to hardcode the node.

Hello, I think this might be because this node calls ReconstructNode() function whenever property “Format” is changed. So node can reconstruct it’s pins according to the Format.

If there was a variable connected, changing of that variable would not trigger reconstructing the node. Also what if the variable is changed in runtime, this would entirely break the pins for FormatText.

If anyone has better answer correct me please :slight_smile: this is what I came up with after briefly analyzing FormatText logic in the Engine.

@Sitiana that’s likely the correct answer for question “why”

@Doctor_Kannon as for “how to solve the problem” - make a c++ wrapper over FText::Format that will accept “format string” and “arguments list” as input parameters.

FText::Format() usage example with named arguments
		FFormatNamedArguments Args;
		Args.Add(TEXT("MyParam1"), "Value1");
		Args.Add(TEXT("MyParam2"), "Value2");

		FText Result = FText::Format("Some text with params: param1: {MyParam1}, param2: {MyParam2}", Args);

@Sitiana I wish I could give each of you a ‘solution’.

@irSoil Thank you for figuring out how to solve the problem.

I was so caught up the BPs that I totally neglected to look at the code. Ultimately, I think the code would look something like this:

FText Result = FText::Format("{MyParam1}", Args);