Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Issues with Vertical Layout Group

Discussion in 'UGUI & TextMesh Pro' started by Jose207, Jun 15, 2015.

  1. Jose207

    Jose207

    Joined:
    May 21, 2015
    Posts:
    41
    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?

     
  2. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Could you post screenshots of inspector so we can look into it
     
  3. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Looks like the "spacing" setting in the vertical layout group is greater than zero. But yes, an inspector screenshot would be of help here.
     
  4. Jose207

    Jose207

    Joined:
    May 21, 2015
    Posts:
    41
  5. LyveIG

    LyveIG

    Joined:
    Jan 8, 2015
    Posts:
    15
    Could you expand the "Padding" sections of these inspectors? These may be related to the problem, too because you have nested vertical/horizontal layouts
     
  6. Jose207

    Jose207

    Joined:
    May 21, 2015
    Posts:
    41
    the padding on all 3 of these is 0 for all attributes
     
  7. LyveIG

    LyveIG

    Joined:
    Jan 8, 2015
    Posts:
    15
    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.
     
  8. Jose207

    Jose207

    Joined:
    May 21, 2015
    Posts:
    41
    yup, that's prob it. Ill change the textures shortly. Thanks!
     
    idurvesh likes this.
  9. Jose207

    Jose207

    Joined:
    May 21, 2015
    Posts:
    41
    I just swapped out the unity assets with ones that I made and that got rid of the gap. Thanks!
     
  10. Jose207

    Jose207

    Joined:
    May 21, 2015
    Posts:
    41
    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?

     
  11. DalerHakimov

    DalerHakimov

    Joined:
    Mar 14, 2014
    Posts:
    302
    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: http://docs.unity3d.com/Manual/script-CanvasScaler.html

    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.
     
  12. Jose207

    Jose207

    Joined:
    May 21, 2015
    Posts:
    41

    Awesome, Thanks DalerHaimov

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

    Jose207

    Joined:
    May 21, 2015
    Posts:
    41
    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?
     
  14. DalerHakimov

    DalerHakimov

    Joined:
    Mar 14, 2014
    Posts:
    302
    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.
     
  15. Jose207

    Jose207

    Joined:
    May 21, 2015
    Posts:
    41
    Thanks DalerHakimov - ill check those out in a bit