UGUI fit parent’s size based on child’s text

In Unity3D, we often wanted to use a huge text box to display lot of text, when we do we wanted to enable the scrollview.
however the default setup of Scrollview didn’t support the text adjustment.
but with a few step you can create your extendable Scrollview based on the text.

To do that, simply apply the following setup on top of the “text” component.
it could be scrollview > Content , or any Panel.

The core idea was this LayoutGroup can control the child’s width/height.
and “Text” component will flee those information based on it’s content size.
but the “Parent” in this case “Scrollview’s Content” had “ContentSizeFitter” component which will use those information to setup it’s own size.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

*

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料