UIAspectRatio ovverides UISizeConstraint?

I’m trying to make a UI bar (sort of like an exp or hp bar) using a frame with UIGradient instead of just a flat colour. The problem is that, if I resize the frame with the gradient, the colors shift along with the frame size, which is expected behavior.
This is what it looks like: Bar with gradient resizing normally.
The red and black keep stretching accordingly.

What I’d like it make is a bar that gradually expands, revealing the black as it gets longer, using the following set-up:
image
The Bar frame is what actually grows in size and has ClipDescendants set to true, while the background actually have its size directly changed, it stays always the same. To keep it the same size the whole time, I’m using these 2 constraints:
image
UIAspectRatio constraint keep the background frame a rectange, while UISizeConstraint should prevent the background Y size from shrinking when the Bar frame is resized, due to the AspectRatio influence.
However, this happens instead:
The background Y size shrinks too, revealing the Bar frame underneat (the white).

PROPERTIES:

  1. Bar Frame:
  2. Background Frame:
  3. UIAspectRatio (the 44.64 aspect ratio is the background’s width divided by the height)
  4. UISizeConstraint (giving it a minimum of 100px in height so it doesn’t shrink, but for some reason it still does shrink)

How can i prevent the frame from shrinking vertically, while keeping the whole thing adaptable on different device sizes? Am I doing something wrong?

Bump? :weary: pls30chars

Another bump… zzzzzzzzz.
I’m starting to think it might be a bug. :weary:

You could run this the first time it runs: You could use this line:

Background.Size = UDim2.new(0,Bar.AbsoluteSize.X,1,0)

Basically, it converts the Scale into an Offset so it doesn’t change everytime Bar is being resized.

You could bind this into an event that fires everytime your viewport (screens, monitors, TVs, fridges) gets resized.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.