How do I vertically center a text widget?
If the text is in a button widget, it can be centered by setting Vertical Alignment.
With justification, it is centered only horizontally.
How do I vertically center a text widget?
If the text is in a button widget, it can be centered by setting Vertical Alignment.
With justification, it is centered only horizontally.
Wrap it with a border
I’m just getting started with Unreal Engine, so where exactly do I need to go? What settings do I need to change? Can you tell me what to do?
The questions does not make much sense in terms of UMG. Unless you want more lines of text.
Select the text block, hold Shift + Ctrl and click the middle icon - this will centre the text in the canvas. You can, optionally, Size to Content
- see screenshot above.
You can make the border invisible if necessary, text can then be centred inside:
But now you must centre the border so we’re back where we stared, that’s why the ask makes little sense.
tl;dr: essentially:
Thank you.
I did it the way you taught me and it worked as shown in the attached image.
I would like to know if you know it,
What is the general method for centering multi-line text horizontally and vertically no matter how the content changes?
With the Unity engine’s UI text, the default setting is to center the text horizontally and vertically, so I didn’t have any trouble with that.
I don’t know what the common method is for the Unreal Engine.
This is the method. Wrapping it with a container and setting Horizontal and Vertical alignment to Center Align
. Precisely what you’ve got up there. The widget must have something wrapped around it to know how to centre itself.
I believe it’s the canvas panel that may be causing some confusion here, hear me out. When hosting widgets, each panel / container:
Will produce a slot:
Text added to a border will sit inside a Border Slot
, text in a Grid Panel will have a Grid Slot with another set of properties:
The Canvas panel is quite special and offers truly unique functionality - anchoring (among other things). In order to have a dynamically sized widget sitting in the centre of the canvas, we need to know its size. You can calculate it yourself and offset the widget or:
The canvas can automagically figure it out if you let it measure it with Size To Content
.
Thanks, I will continue to implement it this way.
If I’m unsure again about the settings or implementation method, I’ll come back to the this forum to ask a question.