Search Unity

Bug Grid Layout's spacing is broken. By A LOT.

Discussion in 'UGUI & TextMesh Pro' started by ItsHofer, Jan 31, 2024.

  1. ItsHofer

    ItsHofer

    Joined:
    Feb 25, 2022
    Posts:
    3
    Hello people, this is my first post and I am not a pro at unity, please excuse my limited knowledge.

    So, I was trying to use the Grid Layout Group to create a grid for level selection, but when I applied it, this happened.
    (The Picture: All the Images I roughly aligned got spread out like crazy, without me touching any settings at all.)
    螢幕擷取畫面 (10932).png
    (Incase the picture not loading, here is an imgur link: https://imgur.com/a/ivHon7Z)

    I went and tried to change all the numbers and settings under the Grid Layout Group, like making the spacing negative, nothing worked.
    I even created a brand new project just to see if I accidently messed with any settings, and it was the same.

    I looked all over the place, no one seems to have the same problem as I do, and by watching Youtube videos, I see that their grids do not act like mine (such as this one: )


    How can I fix this? Not being able to create grids is very painful and annoying, any help is apricated :)
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    602
    I just noticed that you have scale set to 11.762 4.5 can't tell for sure that it's the main culprit for this, but when working with UGUI you should keep the scale of everything at 1 1 1. Use the width/height or top/bottom/left/right properties to control the size, instead of scale.
     
    ItsHofer likes this.
  3. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    Besides the scale using weird values, also be aware that if you don't set fixed column or row counts (check the Constraint values), the grid layout will try to fit your objects automatically. If you only have space for 1 item per row, it'll look like a single column grid. If you want more items per row (i.e. more columns) you need to make your width larger.
     
    ItsHofer likes this.
  4. ItsHofer

    ItsHofer

    Joined:
    Feb 25, 2022
    Posts:
    3
    Thank you, That fixed the issue! I didn't know it would make a difference and basically was using Scale for everything. XD
     
  5. ItsHofer

    ItsHofer

    Joined:
    Feb 25, 2022
    Posts:
    3
    Thanks! That's good to know, it would definitely come in handy.