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. Dismiss Notice

grid layout group - rect size | is there another way?

Discussion in 'UGUI & TextMesh Pro' started by ElDorados, Nov 21, 2016.

  1. ElDorados

    ElDorados

    Joined:
    Nov 20, 2016
    Posts:
    10
    Last edited: Nov 24, 2016
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,139
    Yes, you could just manually create your grid.
    I'm not sure what is wrong with it being smaller? It's on a smaller device, thus it will adjust.
    You should be able to also modify the values of your grid so that the stuff inside is a different size.
     
  3. ElDorados

    ElDorados

    Joined:
    Nov 20, 2016
    Posts:
    10
    the prefabs getting to much smaller, not even the size i set them.
    i was looking for the script, it's pretty hard for me because i'm newb
    if you can direct me to the script or where i can learn it will be great
     
  4. kaplica

    kaplica

    Joined:
    Feb 20, 2014
    Posts:
    87
    If it's a grid layout, then it should have a property called cell size, with that you can specify how big each cell you want to it to be. If you set it to 200x200 then each item will be 200x200.
     
  5. JoaoPaul54

    JoaoPaul54

    Joined:
    Nov 20, 2013
    Posts:
    52
    I believe you do not need to change any sizes. Try to sue the canvas scaler component. you can tell Unity to scale the canvas based on screen size.
     
  6. Izzy2000

    Izzy2000

    Joined:
    Dec 18, 2013
    Posts:
    49
    hmm.. are you looking for the same functionality as my Flowing layout?

    ex: Width affects the Columns, like in a ListView. (in development still)
     
    Last edited: Nov 30, 2016
  7. ElDorados

    ElDorados

    Joined:
    Nov 20, 2016
    Posts:
    10
    thats not what i was asking.. i will edit my topic maybe i'm not clear
    well, that fixes the ui outside the panel.
    it goes like that
    canvas > panel (grid layout group) inside that panel the game load prefabs.
    i need script or other way to replace the grid layout so they can be arranged in two columns and four rows
    i tried to replace the layout grid with yours, couldn't handle it correctly or it just didn't work.
     
  8. JoaoPaul54

    JoaoPaul54

    Joined:
    Nov 20, 2013
    Posts:
    52
    if you have a grid layout can't you change the amount of columns/rows to what you want? or do you need a script to change that?

    you can probably access all the properties of the grid layout with a getComponent<GridLayout>()
     
  9. ElDorados

    ElDorados

    Joined:
    Nov 20, 2016
    Posts:
    10
    Maybe misunderstood, i have a canvas > panel(with grid layout),
    everything is fine.. but the size it displays on phone screen is a lot smaller.
    and i cant fix it with rect size because the grid layout.
    so, i'm thinking maybe i can use script on the prefab it self that fit them to screen resolution and loads them
    like grid layout 2 columns 4 rows.
     
  10. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,139
    Do you have a screen shot of it being a lot smaller on a phone so we can better understand what you are seeing? I have not had issues with a grid layout. It always matches the ratio I'm using.
     
  11. ElDorados

    ElDorados

    Joined:
    Nov 20, 2016
    Posts:
    10
    uploaded.
     
  12. JoaoPaul54

    JoaoPaul54

    Joined:
    Nov 20, 2013
    Posts:
    52
    ok, I completely understood wrong.
    Check your canvas, if it doesn't have one, add a canvas scaler component and play with the options. I believe what you want is the "scale with screen size" option. Other option that I'm thinking of is that your UI is in world space or camera screen space and it could somehow be changed because of that, to make sure it stays the same screen space overlay is probably the most direct one.
     
  13. ElDorados

    ElDorados

    Joined:
    Nov 20, 2016
    Posts:
    10
    already tried canvas scaler,
    inside my canvas i have panel with grid layout
    in there the prefabs loads on start.
    i need script to replace the grid layout so i can use canvas scaler for scale with size.
     
  14. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,139
    No, you shouldn't need a script. The screenshots help greatly, but it feels like something else is going wrong. For example, we use a 4:3 aspect ratio for one of our games.

    The canvas is set to screen space -camera and tied to the main camera.
    The canvas scaler has the following
    UI Scale mode: Scale with Screen Size
    Reference Resolution: x:1024 y:768
    Screen Match Mode: Match width or height
    Match: 1 (matches height)
    Reference pixels per unit: 100

    With these settings everything looks correct even when I add prefabs into a scroll view with a grid or anything that has a grid component. This is also a 2d game, so the camera is Orthograhic, but if you're using screen space overlay, you should be able to do a similar setup.

    Are you using the scroll view that unity has and then the grid is on the content gameobject that is included with it?
     
  15. ElDorados

    ElDorados

    Joined:
    Nov 20, 2016
    Posts:
    10
    i did exactly like you, and it shows really blurry image

    https://s3.postimg.org/arurl47bn/blurry.png

    the grid is on the "panel" inside the canvas.