Feb
23
2016

UI Scroll View automatic Content height

“Hidden” inside the docs ( http://docs.unity3d.com/Manual/HOWTO-UIFitContentSize.html ) you can find details how to make UI ScrollView content to have automatic size based on the child objects. Here’s images how to use it:

– Add “Vertical Layout Group” and “Content Size Fitter” components to the Content gameobject,
– Set “Vertical Fit: Preferred Size” Now your scroll bar will stretch to correct size

unity_ui_scrollview_automatic_content_height_1

– Then your Text gameobject will also have automatic height (enter any amount of text, even if Text “Vertical Overflow” is set to “Truncate”)

unity_ui_scrollview_automatic_content_height_2

*Note: If the Scroll View cannot be scrolled (as if its locked), then add UI/EventSystem to your scene (it was missing on those screenshots)


6 Comments + Add Comment

  • It helped me a lot! Thanks! I just found out your blog and Im starting to dig in! Lots of cool stuff. If I have any question about your posts are you willing to answer them? 😛 Cheers!

    • Hi, yes of course, if can (but if its some generic unity question better ask in unity forums, will get more answers there)

  • that took me forever, thanks alot

  • Great!
    Worked but I had to activate “Child Control Size Width + Height” that it worked!

  • very helpful, thanks

  • still perfect , thx !

Leave a comment

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.