Page 1 of 1

Height of Panel isn't being Refreshed on Runtime

Posted: Wed Jun 26, 2024 11:34 am
by AJWantsToSleep
Hey, short question:

I'm currently building my UI and have used used a vertical layout group so the dialogue panel will grow in height with it's content.

My problem is: Everything looks great in Edit Mode, but during Runtime it just won't refresh the height of the Panel. Is there a easy way to fix this? Thanks! :)

Re: Height of Panel isn't being Refreshed on Runtime

Posted: Wed Jun 26, 2024 11:45 am
by Tony Li
Hi,

You may need to add a Content Size Fitter and set the Vertical Fit to Preferred.

More info: Grouping and Layout Techniques for UI Components

Re: Height of Panel isn't being Refreshed on Runtime

Posted: Wed Jun 26, 2024 11:51 am
by AJWantsToSleep
Hey hey,
Thanks for the quick reply.
I actually have the Content Size Fitter on both Objects (looked at it again just to be sure, but yeah, they were there)

Re: Height of Panel isn't being Refreshed on Runtime

Posted: Wed Jun 26, 2024 12:11 pm
by Tony Li
Try playing around with different settings at runtime in the Unity editor's play mode. When you get it working the way you want, exit play mode and apply those same settings.

Re: Height of Panel isn't being Refreshed on Runtime

Posted: Thu Jun 27, 2024 3:52 am
by AJWantsToSleep
As soon as I change something in the inspector during runtime, the height is displayed correctly again. Therefore, I can't really figure out what is causing the issue.

Re: Height of Panel isn't being Refreshed on Runtime

Posted: Thu Jun 27, 2024 4:02 am
by AJWantsToSleep
I found a solution:
I made a new Script with a LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform); in an LateUpdate.

Re: Height of Panel isn't being Refreshed on Runtime

Posted: Thu Jun 27, 2024 7:57 am
by Tony Li
Glad you found a solution!