Right so which variable represents the currently rendered bounds of a text? I’ve currently set a text object with both vertical/horizontal overflow, and I would like to be able to resize the boundaries of the it’s parent panel based on the bounds generated by the text string, font, and font-size.
Use:
preferredHeight and preferredWidth to find the texts preferred sizes.
2 Likes
Note that you shouldn’t need to do scripting yourself if you just want the parent panel to adjust to the size of the child text (plus optional padding).
Just add a HorizontalLayoutGroup as well as a ContentSizeFitter to the parent. In the new beta 18 there’s also a page in the documentation called “Making UI elements fit the size of their content” with more information.