Make UI always center the panel

80482-unityanswers.png

80483-unityanswers.png

So I have a panel and it´s child is score. So, score keeps on increasing and once I get over 10 the score text is not centered anymore and if I get over 100 the score text would run off the panel… How do I make the score text always center the panel?
Thank you for all the answers!

  1. Set the text that contains the score
    stretch the whole panel. To do this,
    select the text game object - the one that holds the score - and choose stretch
    in the dropdown that sits right under Rect
    Transform (called Anchor Presets). You
    should choose the horizontal and
    vertical stretch, the one that is in
    the bottom-right corner in the
    dropdown.

  2. In the paragraph section of score
    text, choose the middle alignment
    (both vertically and horizontally)

  3. Tick “Best fit” under the paragraph section of the text. ←
    This is the most important part.
    Optionally you may choose the Min
    Size and Max Size for the score text.

Also, make sure you drag the score text’s border so that it completely fills the parent panel. (after setting the Stretch Anchor Preset)