How to stop gui objects from getting smashed when the screen gets smaller

I’m currently making a plugin for my project, but I noticed that whenever I use images or UICorners, the objects get smashed:

Before toolbox was opened:

After toolbox was opened:

is there any way to fix this? I’ve looked through all of the constraints, found nothing that could help.

2 Likes

This is probably because you are using scale. What you want to do is keep the UI at a specific Aspect Ratio, for your case 1:1 because you want to keep everything square.

You can do this either by

  • Using a UIAspectRatioConstraint
    Insert a UIAspectConstraint to your circles
    Changing the AspectRatio property to whatever you want, in this case the default (1) is what you want to keep everything square

  • The SizeConstraint property
    The SizeConstraint property allows you to change which axis the Scale will scale to
    The default value (RelativeXY) will make it so that the X axis is scaled relative to the width of the parent, and Y relative to the height.

    RelativeXX makes it so both the X, Y are scaled relative to the width of the parent
    RelativeYY makes it so both the X, Y are scaled relative to the height of the parent

The UIAspectRatioConstraint will keep the object smaller than the size of it by default.

Another option is to use offset.

4 Likes

You have to play with the size and use AspectRatios

1 Like

Thank you!, I’ve trouble with this in lot a of my other games, I’m glad I am finally able to get a solution.

1 Like

@jmesrje The other option is the real correct one. Please use Offset if you need it.

If Scale isn’t 0, 0.5 or 1 you’re probably doing it wrong.
Stop using really precise scales that will look horrible if your screen is differently sized to the developer’s.

1 Like