Search Unity

How to align UI texts?

Discussion in 'Getting Started' started by alonh82, Mar 6, 2023.

  1. alonh82

    alonh82

    Joined:
    Aug 2, 2021
    Posts:
    1
    I have the following UI scoreboard in which I’m trying to align the different texts
    The top entry is made of 2 main parts:
    On the top right side I have a score and an arrow and on the bottom I have a stats row.
    These 2 rows are aligned horizontally to center.


    On the left there is the user image and name: the background is expanding with the name and this whole block is aligned horizontally to center also, this is working.

    What I can't figure out is how to align both sides to center if either grows.


    To complicate things even more I have the rest of the score entries which are all expanding from left to right and I would like to align them as a whole to the center

    To achieve this I’ve used a Horizontal layout group and content size fitter.
    I’m pretty sure I can make this alignment with code but I wonder is there another easer way to do this.
    Thanks