Skip to content

Text Graph Property

Adding Formatted Text to a Node

  • SMTextGraphProperty types can be added to blueprint or native state classes.
  • A blueprint graph is automatically created which utilizes a format text node.
  • When text is committed variables and pure functions are extracted.

Video Demonstration

Variables and Functions in Text

  • Variables directly in the owning blueprint can be drag and dropped onto the text body.
  • Pure return functions may also be placed.
  • Names can also be typed out: I format text for you and can accept variables like {StrVariable}.
    • Anything between the brackets {} will be considered for parsing.
    • Adding a ` character beforehand will prevent parsing, such as: `{StrVariable}
  • If a variable or method isn't found it will be marked in red and give a compile error.

Handling Object Types

  • The default handling when placing an object in the text field is to use UE4's built in ToText conversions.
  • You can specify your own type of conversion function to use.
    • Define the conversion function on the object type that will be placed.
    • The function needs to be blueprint pure and return Text.
      • Base classes work for storing the function when placing children.
      • Interfaces should work if defined in C++ with const but can't if defined in blueprints because they need to be blueprint pure.
    • On the TextGraphProperty expand the Text Serializer.
    • Under To Text Function Names add your function name.
    • When first adding the conversion function name you'll need to make sure the object blueprint with the function is compiled, the state class that holds the text graph is compiled, and the state machine you're using is compiled.
    • To verify it's working once you place your object in the text field you can right click on the property and choose Go to Property Graph. You should see your new function in the graph.

Further Graph Customization

  • It's possible to directly edit the Text Graph by right clicking on the property and choosing Convert to Graph Edit.
  • Once in graph edit you won't be able to edit text on the node again unless Revert to Node Edit is selected.
  • Switching back to node edit will reformat the text graph, so you should stay in one mode or the other.

Getting the Text Result

  • Unlike normal GraphProperties exposed on the node, TextGraph properties won't automatically evaluate when a state starts, and instead are on demand.
  • To evaluate in blueprint you only have to break the struct. This process evaluates the graph. The Result contains the formatted text output.
  • To evaluate in C++ call Execute() on the TextGraphProperty. Then read the Result.

Current Limitations

  • Only variables and functions directly in the owning blueprint may be used.
  • Parameters cannot be passed to functions.
  • Changing the type of a variable or function that's in use in a text graph may not always update the graph pins correctly and the text may have to be recommitted.