Search Unity

Bug Text.renderer.bounds is incorrect (while fallback font in use)

Discussion in 'UGUI & TextMesh Pro' started by zdolezal, Apr 16, 2021.

  1. zdolezal

    zdolezal

    Joined:
    Sep 27, 2017
    Posts:
    75
    I am using this to set the Sprite size under the text.

    Code (CSharp):
    1. float xSize = Text.renderer.bounds.size.x + 50;
    2. SpriteRenderer.size = new Vector2(xSize, SpriteRenderer.size.y);
    upload_2021-4-16_14-6-43.png

    [HELP WANTED] But it's not working when Fallback font is in use 新车站. The Text.renderer.bounds has no dimensions.

    upload_2021-4-16_14-8-23.png

    [OPTIONAL] And when you mix the characters from normal font with fallback chars, it behaves even more weirdly
    upload_2021-4-16_14-10-56.png
     

    Attached Files: