Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

GridLayoutGroup Padding

Discussion in 'UGUI & TextMesh Pro' started by ThomasVandenberghe, Nov 20, 2014.

  1. ThomasVandenberghe

    ThomasVandenberghe

    Joined:
    Feb 28, 2014
    Posts:
    22
    Currently cell size and spacing are using floats. But Padding is a RectOffset which contains 4 integers.
    Since my world space canvas uses small values (2d camera height is 2 units), a padding of 1 would offset my cells by 384 pixels on a non-retina ipad.

    Are there any plans on changing this RectOffset to use floats or is there another workaround?
     
    N8W1nD likes this.
  2. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    There were no plans on this but it would probably be a good idea. Noted for consideration!
     
  3. fusecore

    fusecore

    Joined:
    Oct 3, 2013
    Posts:
    16
    The padding being int is such a hoser, in which situation does this work out?
    I'm building a world space UI for VR and padding in terms of 1 world space unit is a little.. much.
     
    N8W1nD, Wattosan and karinarigby like this.
  4. LooksConfused

    LooksConfused

    Joined:
    Feb 17, 2020
    Posts:
    16
    I was facing the same issue as described in this post, but after a bit of research figured out that the issue (at least in my case) stems from a poor canvas setup..

    It turns out that the trick is to ensure that the canvas width/height is somewhat defined as something resembling pixel values, and then the physical size of the canvas in world space should be defined by changing the scale (typically to something very small).

    This setup makes it so that any children of the canvas behaves much nicer in terms of anchoring/stretching, and the padding on layout groups also becomes usable since the int value will be in relation to the width/height of the parent, but scaled down through the canvas.

    The first few minutes of this video describes the setup nicely:
    https://blogs.unity3d.com/2014/06/30/unity-4-6-new-ui-world-space-canvas/
     
    martynpwilson and Nit_Ram like this.
  5. Lorin_Atzberger

    Lorin_Atzberger

    Joined:
    Dec 11, 2013
    Posts:
    119
    I'm working on a pixel art game, with a world space canvas for a few things. I can't just make it arbitrarily larger. Everything was going really well until I hit this bump.
     
  6. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Using integer values for padding is such a nonsense.
    My world-space canvas was using a neat 1x1 size to simplify calculations. And now I have to resize it to something like 2000x2000 because someone at Unity decided that int for coordinates is fine (and fun probably).
     
    gcmobx and Lorin_Atzberger like this.
  7. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    531
    I'm facing the same problem actually.

    My cells size are set to .1, and I'm unable to arrange them in that grid if the padding is 1
     
  8. gcmobx

    gcmobx

    Joined:
    Apr 12, 2014
    Posts:
    2
    Especially since for the same components, the 'spacing' field allows for floats. Does Unity not go the same processes of Game development and encounters the same pains and issues as us??
     
  9. Volorf

    Volorf

    Joined:
    May 9, 2017
    Posts:
    9
    Oh, it's just ridiculous. Ints for paddings?

    Does anyone solve this issue (I use it for VR)?

     
  10. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Seems not, because they fired the internal team behind the Gigaya project, so no eating of their own dog food.
     
  11. jonathanqfxw

    jonathanqfxw

    Joined:
    Jan 27, 2019
    Posts:
    1
    I solved the problem by copying the code for LayoutGroup and writing my own CustomLayoutGroup to override the integer padding with floats. Here's my code for anyone interested
     

    Attached Files:

  12. HouseTrapDev

    HouseTrapDev

    Joined:
    Oct 23, 2020
    Posts:
    4
    lmao that's actually hilarious - arbitrary decade-old limitation in the engine? Just copy the code & fix it yourself!

    Truly makes me wonder why this hasn't been implemented. Such a basic feature.