Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    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:
    5,749
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,575
    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:
    5,749
    thanks.
    what are margins for?
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,575
    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:
    5,749
    I see. thanks.