UICorner Breaks With Negative GuiObject Size

UICorner modifiers added to a GuiObject with a size that is negative on any axis will not show any change, instead of rounding the corners like normal. I use negative GuiObject sizes consistently, and this is causing issues in my game.

image
image

Repro Steps

  • Add a ScreenGui with a Frame inside into StarterGui
  • Add a UICorner into the Frame
  • Give the Frame a size that is negative on at least one axis.
  • The Frame should now remain completely square regardless of UICorner settings.

I’m assuming this has been happening since the release of UICorners. I imagine the cause of this is due to how the radius of the corners is limited to half the size of the GuiObject - this calculation probably doesn’t use the absolute value, and thus interprets its maximum radius as being less than 0 in the case of a negatively sized object.

6 Likes

Don’t do this, it’s not supported behavior.

3 Likes

The issue is that there is no other way to offset an element from the right side while using scale for position, offset for size and no scripts.

1 Like

If there is some situation that’s not solvable without negative size you should make a feature request, it doesn’t change the fact that negative size isn’t supported and thus you will sometimes run into broken behavior like this if you use it.

AnchorPoint even goes a long way towards making situations where negative size may have been useful in the past intuitive to solve in a supported way.

2 Likes

AnchorPoint of (1, ?), Position of 1 scale and -offset, and size whatever you like will do this.

Or if you wanted a scale offset, position of 1-(scale offset) will do it.

E.g. if I wanted something in the top right corner, with 0.1 scale offset to the edges,

AnchorPoint (1,0)
Position {0.9, 0},{0.1, 0}
Size {anything you want, positive}

And likewise if the offset was to be 12 pixels,

AnchorPoint (1,0)
Position {1, -12},{0, 12}
Size {anything you want, positive}

3 Likes

Documentation doesn’t say anything about this, so bug report is on-point:

It should either be fixed or documentation should be written mentioning this. Studio lets you get into this case so it is definitely undesirable behavior.

4 Likes

The closest we have is just that it’s “better” not to:

Although it is possible to use negative sizes when creating GUIs, it’s more often better to manipulate GuiObject.AnchorPoint instead.

Studio only “lets you get into this case” insofar as UDim2s inherently let you specify sizes where it’s unclear whether it’s possible for a negative size to manifest when the object is eventually used in context. The visual UI editor does not let you create Guis with negative sizes.

It will be. The documentation mentioned above should not be endorsing negative sizes.

2 Likes

what are we supposed to use then??

You shouldn’t ever need negative sizes. Anchor point with positive Size and positive or negative Position values should get whatever you need.

If you’re finding yourself needing to use negative sizes, then post in #help-and-feedback with your specific issue and someone will be able to advise on the correct properties with a positive Size to achieve the same effect.