Issues with Vertical Layout Group

Hi Guys,

Im laying out a new screen, and I am getting a gap between 2 panels. I have a parent panel that has a vertical layout group. It has 2 child panels that each have layout elements controlling height. I can’t figure out how to get rid of the gap between the 2 child elements.

Any thoughts?

Could you post screenshots of inspector so we can look into it

Looks like the “spacing” setting in the vertical layout group is greater than zero. But yes, an inspector screenshot would be of help here.

Could you expand the “Padding” sections of these inspectors? These may be related to the problem, too because you have nested vertical/horizontal layouts

the padding on all 3 of these is 0 for all attributes

If I see this correctly, you use the default textures from Unity. They are the root of your problem because they have a transparent border without any content.

yup, that’s prob it. Ill change the textures shortly. Thanks!

1 Like

I just swapped out the unity assets with ones that I made and that got rid of the gap. Thanks!

Another question,

Is there a way to have text size adjust based on screen size?

For example, in the images attached. I like how the text is displayed on the image on the left (iPhone 4 Wide) but when scaled up to the image on the right (iPhone 6 wide) the text is still the same size. I would ideally, like to be able to have the text scale up or down to fit different resolutions

Any thoughts?

The root UI gameobject Canvas has the script attached to it. It’s named as Canvas Scaler. Choose the option Scale Mode->Scale with Screen Size and adjust the Reference Screen resolution.

Official Docs: Redirecting to latest version of com.unity.ugui

As the Text is a part of UGUI, it’s just like other UI objects, Image, Panel, Buttons, and etc etc. Once you have properly configured the Canvas Scaler, it will scale up&down perfectly.

All my mobile game UI, Menu created using the UGUI and I don’t have any issues with scaling. It fits perfectly in all possible resolutions, as I want.

Awesome, Thanks DalerHaimov

Im going to try that in a bit. My goal is too also have UGUI screens that scale perfectly across resolutions

Cool, this definitely works way better. The layouts work 99% of the time. My only issue now is that when i switch to either of the iPad resolutions a certain text field always disappears. Any idea on how to trouble shoot this?

1.Did you deploy it to the actual device? I do use the Unity 5.0.2 and from time to time the texts disappear in the editor for me also, though I don’t change any resolutions. And it comes back when I go to play mode.
2. It also can be the height or width of your text field. Look at Transform property of the text field and try to put higher values.

Thanks DalerHakimov - ill check those out in a bit