QUICK DEV TIP #08 UE4 - MULTI-LINE TEXT!

This week I’ve got an extra quick one for you. I use this one pretty constantly when working in Unreal and it will help keep your text orderly and readable.

Did you know that you can easily split text onto a new line by pressing Shift + Enter.

In the example below my comment is overlapping another node making it hard to read. I can easily fix this by clicking on the comment text field at where I want to create a split and then using Shift + Enter to force the text onto a new line. I generally like to make it wrap around the length of the node.

SQ_08_MultiLineText_ForBlog03_Combined.jpg
 

One place I commonly use this is on comments for branch nodes. I find splitting the comment onto two separate lines makes for an easier quick read (probably because it matches the execution pin layout on the node itself). I particularly like to do it on branch nodes because if the branch node is far away from the origin of the bool value it can help you to quickly work out what the bool does.

 

This Shift + Enter line split can also be used with the Text Render Actor, which allows you to have text in the world.

SQ_08_MultiLineText_ForBlog05_TextRenderActor.jpg
 

When working with UI inside of unreal, there are a bunch of different ways to split text onto multiple lines. The first method you could go for is trying UMG’s text wrapping as you can see in the image below. Although, this has issues with not being able to control where the split happens, as you can see below:

SQ_08_MultiLineText_ForBlog06_AutoWrap.jpg
 

Next up you might try having two separate text fields within a vertical box. This is visually what we are after but you would get a small overhead for using multiple widgets.

SQ_08_MultiLineText_ForBlog07_VertBox.jpg
 

The best way if you haven’t already guessed it would be to simply use a Shift + Enter in the text field where you want to split! Quick, easy and gets the job done.

SQ_08_MultiLineText_ForBlog08_ShiftEnter.jpg

If you want more tips and tricks make sure to give me a follow on Twitter @cbGameDev