Preserve ratio of sliced image through SpriteEditor

Hello !

I have the following (sliced) sprite :
7881937--1002730--upload_2022-2-9_11-36-30.png

I use the sprite (not the texture) in UI Builder :
7881937--1002736--upload_2022-2-9_11-39-53.png

The arrow keeps the same width when resized horizontally, as expected :
7881937--1002739--ArrowKeepWidthAspect.gif

However, the arrow is deformed along its height when resized vertically :
7881937--1002742--ArrowDeformAlongHeight.gif

I can see cases where this is useful and expected, but it does not suit my case :stuck_out_tongue:

I cannot put my finger on what I’m doing wrong, if I am not implementing this correctly, or if there’s a bug. ^^"
Does anyone have an idea ? (how to implement this correctly, how to workaround the issue…)

The way 9-slices work is that the left/top/right/bottom part of the 9-slices will keep their relative sizes while the center part will stretch.

In your example, since there are no top/bottom slices, it’s all part of the center, which is stretchable.

I’m not sure what is the expected behavior here, so I can’t provide a workaround. Can you please provide more details about what you would expect to happen when you stretch vertically?

Sorry for my confusion : there was indeed no way my use case would be solved by 9-slicing ^^"

I would like the end of the arrow to not stretch vertically.

This would mean that this VE (outer end of the arrow in red)…
7888201--1003819--upload_2022-2-11_11-11-11.png

… would look this way when stretched vertically…
7888201--1003831--upload_2022-2-11_11-19-28.png

instead of this :
7888201--1003834--upload_2022-2-11_11-19-42.png

I’m unsure what would be the best way to implement this in the builder :smile:
(e.g. separate the outer end of the arrow and do something so it can preserve its aspect ratio ?)

Yes, I think using multiple VisualElements here is the way to go. You can probably assemble them in a common parent, and with the proper flex values, you can probably make it behave the way you want.

1 Like