I’ve been doing some UI work in my game and a problem that I’ve had before has reared its head again.
Each of the white text labels are spaced {0.1,4} away from the one above. However, the gap is not uniform. The gap between “Finished Round” and “Difficulty Multiplier” is definitely 10% of y, and 4 pixels…
None of the TextLabel’s have a BorderSizePixel of 0.
So I tried using scale exclusively. Positioning every text label {0.11,0} away from the one above; to give a buffer of 0.01 * Y. This seemed to work. (see below) The problem with using pixels for a defined border length is an annoying one though.
This is most likely due to rounding. To get the actual offset, they multiply the scale by the screen size and add to that the offset values. If it’s not an integer, it needs to be rounded, because it needs to be displayed on the pixel grid. I wouldn’t say it’s a bug.
Example: say I have a screen width of 1234 pixels and I want 1%, 5% and 9% of that. That would be 12.34, 61.7, 111.06 pixels when you multiply the scales with the actual width. When rounded, that becomes 12, 62, 111, which are not equally far apart, even though there was 4% between them all in their definition. You can’t really get around this.
That makes a lot of sense. Using scale exclusively does seem to fix the issue though (I assume its because the rounding error is the same for each label).
I think it’s just the particular case of your screen size and your label positions that are making it work, I don’t think that’s the case in general. My example has only scale too, and it also has non-uniform offsets. (and you should assume a player can have any possible screen size, because they can play windowed as well)