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?
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.
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:
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.
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).
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??
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