Skip to content

Text Graph Property

Text Graph Poperties are a struct type you can add to any state class. They allow you to quickly edit text on a node while also formatting variables for you.

Adding Formatted Text to a Node

  • SMTextGraphProperty types can be added to blueprint or native state classes.
  • A blueprint graph is automatically created in the owning state node 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

You may want to place an object type directly in text and convert it to a readable string. The default handling when placing an object in the text field is to use Unreal's built in ToText conversions.

You can specify your own type of conversion functions to use.

  1. Define the conversion function on the object type that will be placed in the text.

    • 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.
  2. On the TextGraphProperty expand the Text Serializer.

  3. You have two options.

    1. The easiest way is to enter your function name under ToTextDynamicFunctionName.
      • This function is dynamically looked up during run-time allowing you to place even a UObject type in the text. As long as that UObject has the function available in run-time it will work.
    2. The second way is to add a function under To Text Function Names.
      • These are compile time constant functions. The object type you place in the graph must have the function available at compile time. This is not compatible with generic UObject types.
  4. 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.

  5. 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.