Replies: 2 comments
-
Hey @thelwh, thanks for the question. Short answerUse a Long answerThe library used in this package, Yoga, has this thing called the "measure function". Measure functions are used by Yoga to ask us what's the size of the nodes, for example how big a text or image is. In our case, we are using Unity UI as nodes, so we use Unity UI's layout API in our measure function, more specifically unity-flex-ui/Runtime/FlexLayout.cs Lines 759 to 790 in 30ea7a5 For texts in Unity UI (both the legacy Text and TextMeshProUGUI), its preferred size only matches the content size automatically after updates if you add a |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply. |
Beta Was this translation helpful? Give feedback.
-
I want to change the font size of TextMeshProUGUI and keep the recttransform of textmeshpro fit the text size just like ContentSizeFitter.
I found when the textmeshpro gameobject active state change and layout refresh,text transform will fit text size,so I think it's no need to add the ContentSizeFitter component.
I try to call
FlexLayout.RefreshRootLayoutImmediate()
after change the font size,but it only work the first time.When I change the font size and callFlexLayout.RefreshRootLayoutImmediate()
again,it seems no longer work.I also try
FlexLayout.RefreshRootLayout()
,and it work in the case of setting the font size smaller,but when set the font size bigger the layout is incorrect.So please tell me what is the correct way to achieve it.
Beta Was this translation helpful? Give feedback.
All reactions