Search Unity

How to add multiple alignments in a style tags?

Discussion in 'UGUI & TextMesh Pro' started by MicroEyes, Oct 7, 2019.

  1. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    I am using v1.5.0 (latest) version of TMP.

    I am trying to create a style with <align> tag and values "center" and "middle". I have tried so far:
    <align="center,middle">
    <align="center|middle">
    <align="center"><align="middle">
    but none of the above are working and only the first one "center" is working.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Only Left, Center and Right is supported with the <align> tag as this tag affects the text enclosed in the tag. Ie. In the same text object, you can only affect horizontal alignment of lines or blocks of text. Not control vertical alignment which is applied to a whole text object.

    Can you provide an example / use case of what you are trying to do with this?
     
  3. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Hi Stephan,
    Please see the attached image. I have 10-15 TMP_Text elements in my game, which will be sharing common font, size, horizontal align, vertical align and color. So I decided to go with using stylesheet feature and assigning styles to each TMP_Text component without any specific change to settings itself.


    Besides the above case, I have lots of TMP_Text elements that will be based on styles.
     

    Attached Files:

  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The key limitation here is the <align> tag which by design only affects horizontal alignment of lines or blocks of text.

    So if a text object requires specific vertical alignment for the whole text object, you have to use the alignment property or one or the new verticalAlignment property introduced in 1.5.0 that make it easier to set horizontal and vertical alignment separately.