Hello Guest

Author Topic: How to get pixel width of textmesh  (Read 14263 times)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to get pixel width of textmesh
« Reply #15 on: December 17, 2014, 05:29:31 pm »
You're doing that wrong, you're offsetting each word by the length of the extents (which is wrong btw, you should just return the bounds from AddBackground, because of all that is accounted for in there).
You want to set the nextOffset to bounds.max.x, which should place it immediately after the first text.

Second issue is your anchor for the text mesh is the middle center, in order to position the text mesh, you will first need to figure out the size of the string, etc. If you set anchor to bottom left, the position = the bottom left, i.e. you dont need to know the width of the new text mesh to determine its position, i.e. its position = previousBounds.max.x + wordSpacing.