UIScale does not stack

Not sure if this is a bug or behavior that didn’t exist previously. I found no threads about this so I assume it was working before! (And the documentation doesn’t mention anything about only supporting 1)

The issue is that multiple UIScale objects do not work inside gui elements. It seems to pick one of the UIScales (whichever was added first) and will be bound to this UIScale until it is removed (see video)

Expected behavior: UIScale will stack so if I have two UIScale.Scale = 0.5, the result is 0.25.

This is more or less intended behavior since you can just multiply the scale values together yourself and use a single UIScale. Most other UI components you can only have one per object, for example you can’t stack UIPadding objects or UISizeConstraint objects.

This would definitely have not worked at any point in the past, so that’s not why nobody has made threads about it.

I use a UIScale to do Open/Close tweens on my UI, but some of our UI needs to be scaled down to fit on smaller mobile devices. I don’t want to have to adjust all of my Gui tween functions to support checking if there’s a mobile UIScale in them.

tl;dr I want to be using Roblox as my UI framework rather than making my own!

I’m not sure the behavior you want is clear in the case of UIScale stacking. For example, if I have a UIScale of 1, and a UIScale 0.5, should the scale end up being 0.75, or 0.5, or 1.5? It’s hard to know the intent of a stacked scale.

We have recently moved to componentizing UI so devs don’t have to pay the cost of all possible functions/behaviors existing on all UI objects at the same time. This cost is both in terms of memory and ease of use (eventually everything in the UI system would have a ton of properties and methods, even if they are rarely used). In the past we would of just added a Scale property to all UI objects, which would have the same problem you are describing.

I do think we could make it easier to visualize in studio about what is going on in situations like this, so it’s easy to understand why something isn’t working as one may expect at first glance.

A scale is multiplied, so having two scales of 1 and 0.5 would result in 0.5.

As things stand I’ll need to write a wrapper on top of UIScales to support looking for a “PhoneScale” and doing the multiplications manually. This will cause some conflicts with dynamically switching between platforms.

It would be nice if UIScale could support this functionality so I didn’t need to include a wrapper anywhere I want to support it in our projects :frowning:

3 Likes