Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i use TextBounds?

Asked by 9 years ago

It all says in the title of the question^^^

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

TextBounds is a Vector2 value corresponding to the size on screen in pixels that text takes up.

As far as I know, it will only populate correctly / immediately for LocalScripts (a comment for someone who knows better would be good), and for objects which have their Parent set.

As a Vector2, it is very similar to a Vector3, except that it only has a .x and .y component and not .z. It still has a .unit and .magnitude but for the purposes of text layout those will be meaningless.


TextBounds can be used to fit multiple elements of text (usually of different styles) together while still obeying the natural spacing of the font by computing where the position of further text should be after computing the position and size of other text.

Ad

Answer this question