Resize parent to text in one direction

[SOLVED]

Hello All,

I am currently using the Content Size Fitter and Vertical Layout Group to resize a UI image to properly fit the amount of text inside that image dynamically. However, I notice that this results in the UI image resizing both in the positive and negative y axis. Moving the image both up and down to fit the text. However, I am looking to have the box only expand in the “up” , positive y, direction to resize to fit the child text component.

Has anyone ever done this before or have a solution?

Thanks!

1 Like

Solved my problem. All I had to do was adjust the location of the pivot on my Parent object to have it rescale/expand in one direction!

6 Likes

holy shit it actually works

Can you explain how you did this?

I’m not following the original post’s meanings.

1 Like

I know this is an old thread but for anyone else wondering how the OP may have changed the pivot of the parent object, all you need to do is alter the Pivot properties in the parent’s RectTransform. For instance, I have a vertical layout and I wanted my text to extend my parent’s image downward only, so I changed the y-axis pivot from 0.5 to 1.

1 Like