Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question textmeshpro: how do you center the text box around the pivot?

Discussion in 'UGUI & TextMesh Pro' started by laurentlavigne, Sep 9, 2022.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,436
    upload_2022-9-9_8-39-41.png
    none of the rect coordinates change as i move the handles so that must be elsewhere

    upload_2022-9-9_8-40-11.png
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    The text box should always be centered around the pivot. That is unless you changed the margins with is the yellow box.

    The white dots are to control the margins whereas hovering over the lines between those dots changes the RectTransform size as seen below.

    upload_2022-9-9_23-43-5.png

    To Reset the margins, look in the Extra Settings panel of the text component as seen below. This is where you can change their values numerically instead of via the white dots / widgets.

    upload_2022-9-9_23-44-36.png
     
    laurentlavigne likes this.
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,436
    thanks.
    what are margins for?
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Just like on a piece of paper, they allow you to offset the text within the RectTransform.

    Think of the RectTransform as your piece of paper and the margins as the thing that allows you to offset the text within it.

    Below is a screenshot from Microsoft Word where I selected / highlighted the text. Notice how the descender of the "j" is sticking outside of the margin.

    upload_2022-9-10_16-22-3.png

    If you had a masking component on that text, the descender of the 'j' would get clipped. So having the ability to offset the text within the page / RectTransform can be pretty useful.
     
    Last edited: Sep 10, 2022
  5. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,436
    I see. thanks.