Text Graph Property ¶
Text Graph Properties 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 and supporting rich text.
Adding a Text Graph to a Node¶
Text Graph Property structs can be added to all types of 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.
A custom state class:
Always Public
It is not necessary to make this variable public or set it to BlueprintReadWrite
. Text Graph Properties will always be added to a node since there is no reason to include these property types otherwise. It is still possible to mark the property Read Only
or Hidden
.
Video Demonstration¶
Variables and Functions in Text¶
Variables and pure return functions in the owning blueprint can be drag and dropped onto the text body.
Names can also be typed out:
- 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.
- Define the conversion function on the object type that will be placed in the text.
- The function needs to be
blueprint pure
and returnText
. - 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.
- The function needs to be
- On the TextGraphProperty expand the
Text Serializer
. - You have two options:
- The easiest way is to enter your function name under
To Text Dynamic Function Name
.- This function is dynamically looked up during run-time allowing you to place even a
UObject
type in the text. As long as thatUObject
has the function available in run-time it will work. - You can also set this globally under
Project Settings
->Logic Driver Text Graph Editor
which allows you to support text graph arrays. This option will always be overridden by any function names declared locally in the text graph'sText Serializer
.
- This function is dynamically looked up during run-time allowing you to place even a
- 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. - 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.
- 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
- The easiest way is to enter your function name under
- 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.
The state node containing a Text Graph Property with a variable:(1)
ThisSpeaker
is an actor type.
The state class defaults for the Text Graph Property, pointing to a custom function called ToText
:
A custom function defined on our actor class:
What the generated text graph looks like:
The in-game result after evaluating the Text Graph Property:
Graph Edit¶
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 to Node Edit
Is Destructive
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 properties exposed on the node, Text Graph 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.
Splitting the struct pin is also an option.
Rich Text (2.7+)¶
Rich text can be displayed within text graph properties. The rich text supports Unreal Engine's UMG rich text.
From a text graph's default settings select the rich text style or decorator classes to assign. This will only be used in the editor. At run-time the original text is output and it is up to your UMG widgets to display rich text.
All rich text will be removed while editing the text graph.
When not in edit mode and a variable is in between rich style attributes, it will also show up as {VARIABLE_NAME}
since Unreal Engine does not support nesting rich styles which variables also use.
Current Limitations¶
- Only variables and functions in the owning blueprint and its parents 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.