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!
Height of Panel isn't being Refreshed on Runtime
-
- Posts: 18
- Joined: Wed Jun 19, 2024 2:44 pm
Height of Panel isn't being Refreshed on Runtime
- Attachments
-
- Edit Mode
- Screenshot 2024-06-26 173119.png (28.73 KiB) Viewed 176 times
-
- On Runtime
- Screenshot 2024-06-26 173135.png (8.25 KiB) Viewed 176 times
Re: Height of Panel isn't being Refreshed on Runtime
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
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
-
- Posts: 18
- Joined: Wed Jun 19, 2024 2:44 pm
Re: Height of Panel isn't being Refreshed on Runtime
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)
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
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.
-
- Posts: 18
- Joined: Wed Jun 19, 2024 2:44 pm
Re: Height of Panel isn't being Refreshed on Runtime
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.
-
- Posts: 18
- Joined: Wed Jun 19, 2024 2:44 pm
Re: Height of Panel isn't being Refreshed on Runtime
I found a solution:
I made a new Script with a LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform); in an LateUpdate.
I made a new Script with a LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform); in an LateUpdate.
Re: Height of Panel isn't being Refreshed on Runtime
Glad you found a solution!