There are three types of text formats in Unreal. It doesn't use the same String class as used in C++ Standard Template Library. Usually for games more efficient libraries are written that sacrifice robustness for performance.
The three data types are Names, Strings and Text.
If you do not know about text types, it might be good to read the history of how we got here in Unicode and Character Sets.
They are FText, FName and FString.
FName are used for names (non-customer facing) of items in the Content Browser. When you name a new asset in the Content Browser, change a parameter in a Dynamic Material Instance, or access a bone in a Skeletal Mesh. This format is 8 bytes per character. It is the smallest format and is used to refer to objects in the editor (like the name of a Material variable). It is also the smallest format and is often used in multiplayer to reduce the size of packets sent, if text needs to be sent between client and server or vice versa. FName is case insensitive. It has very fast look up using hash tables.
FString is a 16 byte format that allows dynamic modification as well as replace, search concatonate etc... It is less performant but is used most often for manipulation.
FText a 40 byte format is for all customer facing text that requires localization (Like the HUD, or buttons in the front end).
Please note that in Blueprints we do not have the built-in char ????CEHCK THIS MARC???? type. You can use it in C++ only but will not show up in Blueprint.
Select the Blueprints folder and right click in the directory and a Blueprint Class and select the Actor class. Call this new Blueprint BP_Text
.
Open up BP_Text. Add a TextRender component and call it Text
. Change the Text to Text
. Adjust the Horizontal Alignment and Vertical Alignment to Center
and Text Center
. Copy and paste the color from BP_Frac. Change the World Size to 72
.
Drag the Text component onto the graph. Then drag off the pin and select a Set Text node. Connect the execution pin to Begin Play.
Now lets demonstrate the three text types (they will all look identical) by adding a Make Literal String , Make Literal Text and Make Literal Name node. Then add
I am a string
I am a text
I am a name
to the appropriate Literal.
Now change the Text to say String-TextName
.
Now connect the Make Text Literal output to the Set Text | Value pin.
Drag a copy of BP_Text to the level. Rotate it to face the camera.
Press the Play button and you will see it print I am a text.
You can see that if we connect Make Literal Name to the value pin we will see in game I am a name.
Now when you don't initialize an FString
or FText
, it is an empty string "". With an FName
it defaults to none
as it is used. Delete all the text and run the game, and you will see it print none.
To prove this go to the Text Literal and remove the text. When you run the game no text prints at all (empty text).
Test the String Literal to print I am a string. Put the text back to:
I am a string
I am a text
I am a name
previous | home | next |
---|