What is Print String?
The Print String node in Unreal Engine just outputs a string to the log, screen, or both.
There is only one executable output from this node and the following inputs:
- In String: Enter the text you want to output, or connect an input to view its value.
- Print to Screen: If set to true, this option will display the “In String” input on the game’s screen.
- Print to Log: If set to true, this option will print the “In String” input on the Output Log.
- Text Color: To change the color of the text, double-click on the color box.
- Duration: Enter the time in seconds that the text should be visible on the screen.
- Key: If a non-empty key is provided, the message will replace any existing on-screen messages with the same key.
What is a String?
A String is a data type in programming that is used to represent text messages. It is made up of a set of characters that can include text, spaces, numbers, and symbols.
How to use Print String in Unreal Engine?
- Search for the Print String node by right-clicking on the Blueprint Event Graph.
- Connect the output you want to debug to the Print String node’s “In String” input. Alternatively, in the “In String” field, enter the message you want to display.
- Play or simulate the game, and the message will be printed to the screen or log as specified in the Print String node.
In Unreal Engine, you can mix custom text and a return value by connecting an “Append” node to the Print String.
To make the most of Print String you can add as many pins in the append as you need. Simply press the “Add pin +” button.
Alternatively, you can also use the “Print Text” node.
It will do the same function, but it will return a Text variable instead of a String variable.
Text variables may be combined with a “Format Text” node.
How to change the font size of a Print String in Unreal Engine?
- Go to Project Settings and search for “Small Font” in the top search box.
- If you have some True Type fonts imported in the project, select one.
- Open the custom font by double clicking it in the Content Drawer, then modify the “Legacy Font Size” in the details window.
- The text should now be bigger after restarting Unreal Engine.
Show Warnings and Errors in the Output Log
This Unreal Engine tip is simple, but it might be quite helpful.
By prefixing a Print String with either Warning: or Error:, you may modify its color in the Output Log.
Errors are shown in red, while warnings are displayed in yellow.
Keep in mind that the Output Log is where this trick will actually work, not on the screen.