Height of Panel isn't being Refreshed on Runtime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
AJWantsToSleep
Posts: 18
Joined: Wed Jun 19, 2024 2:44 pm

Height of Panel isn't being Refreshed on Runtime

Post 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! :)
Attachments
Edit Mode
Edit Mode
Screenshot 2024-06-26 173119.png (28.73 KiB) Viewed 176 times
On Runtime
On Runtime
Screenshot 2024-06-26 173135.png (8.25 KiB) Viewed 176 times
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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
AJWantsToSleep
Posts: 18
Joined: Wed Jun 19, 2024 2:44 pm

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

Post 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)
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
AJWantsToSleep
Posts: 18
Joined: Wed Jun 19, 2024 2:44 pm

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

Post 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.
AJWantsToSleep
Posts: 18
Joined: Wed Jun 19, 2024 2:44 pm

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

Post by AJWantsToSleep »

I found a solution:
I made a new Script with a LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform); in an LateUpdate.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad you found a solution!
Post Reply