Search Unity

Question Help with Scroll View & Dynamically resizing UI

Discussion in 'UGUI & TextMesh Pro' started by Kezley, Mar 1, 2023.

  1. Kezley

    Kezley

    Joined:
    Nov 26, 2019
    Posts:
    1
    Hi guys!

    I've been trying to put together a modal window based on this video, and although I love Game Dev Guide I do wish that he'd go slower and/or provide links to the project to go through afterwards.

    What I'm trying to create is a modal window that's header (a title) and a footer (with buttons) will dynamically grow horizontally to fit with the content, which is a container for a scrollview and parented to the content object in the scrollview is a TextMeshPro Text widget.

    I want the content to grow vertically and horizontally to fit the text, but to have a max growth in width and height. Once it reaches this point, the text can just grow vertically and the scroll bar can appear.

    I have been looking for days through different tutorials but none of them have had these discrete answers and I'm hoping someone here can help me, because I'm struggling to get in my head what UI components in which combinations perform a behaviour.

    TLDR:

    • How can I have an element grow up to a max width and/or height and not below a min width and/or height?

    • With that, how can I have a scrollview grow dynamically based on its content (all the elements, not just the Content child object and the text element) up to a max or shrink based on its contents down to a minimum value?
    Thanks so much for reading, I really need some help here