{"id":2276,"date":"2020-06-16T17:47:11","date_gmt":"2020-06-16T09:47:11","guid":{"rendered":"https:\/\/www.clonefactor.com\/wordpress\/?p=2276"},"modified":"2020-06-16T17:47:13","modified_gmt":"2020-06-16T09:47:13","slug":"ugui-fit-parents-size-based-on-childs-text","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/program\/unity3d\/2276\/","title":{"rendered":"UGUI fit parent&#8217;s size based on child&#8217;s text"},"content":{"rendered":"\n<p>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.<br \/>however the default setup of Scrollview didn&#8217;t support the text adjustment.<br \/>but with a few step you can create your extendable Scrollview based on the text.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"813\" height=\"564\" src=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/ParentAdjustSizeBasedOnChild.jpg\" alt=\"\" class=\"wp-image-2278\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/ParentAdjustSizeBasedOnChild.jpg 813w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/ParentAdjustSizeBasedOnChild-300x208.jpg 300w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/ParentAdjustSizeBasedOnChild-768x533.jpg 768w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/ParentAdjustSizeBasedOnChild-359x249.jpg 359w\" sizes=\"auto, (max-width: 813px) 100vw, 813px\" \/><\/figure>\n\n\n\n<p>To do that, simply apply the following setup on top of the &#8220;text&#8221; component.<br>it could be scrollview > Content , or any Panel.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"811\" height=\"355\" src=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/uguiTextControlParentSize.jpg\" alt=\"\" class=\"wp-image-2277\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/uguiTextControlParentSize.jpg 811w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/uguiTextControlParentSize-300x131.jpg 300w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/uguiTextControlParentSize-768x336.jpg 768w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/06\/uguiTextControlParentSize-359x157.jpg 359w\" sizes=\"auto, (max-width: 811px) 100vw, 811px\" \/><\/figure>\n\n\n\n<p>The core idea was this LayoutGroup can control the child&#8217;s width\/height.<br>and &#8220;Text&#8221; component will flee those information based on it&#8217;s content size.<br>but the &#8220;Parent&#8221; in this case &#8220;Scrollview&#8217;s Content&#8221; had &#8220;ContentSizeFitter&#8221; component which will use those information to setup it&#8217;s own size.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Unity3D, we often wanted to use a huge text box &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[67],"class_list":["post-2276","post","type-post","status-publish","format-standard","hentry","category-unity3d","tag-ugui"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/2276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2276"}],"version-history":[{"count":1,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/2276\/revisions"}],"predecessor-version":[{"id":2279,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/2276\/revisions\/2279"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}