9 Slicing not working for UI Image

I followed the instructions here Unity - Manual: 9-slicing Sprites

But I still can’t get my Image to resize properly. As I increase height it scales the top section. My understanding is that it should not scale the top, bottom, left or right sections of the images if I am stretching the sprite to make it bigger.

Lots of posts on this topic but no solution that I could find.

I am not using scale. I am increasing height.

I don’t see anything wrong here. It works perfectly as it should. You may have the wrong idea about a 9 slice? There are 9 sections, lets label them like this:

// /-----------------\
// |  1  |  2  |  3  |
// |-----------------|
// |  4  |  5  |  6  |
// |-----------------|
// |  7  |  8  |  9  |
// \-----------------/

Note that section 1, 3, 7 and 8 are the only sections that are not scaled.

Section 2 and 8 are only scaled horizontally. So their height stay the same, but their width changes.

Section 4 and 6 are only scaled vertically. So their width stay the same but their height changes.

Section 5 is the only section that is scaled in both axes.

So you can not have a nicely designed fixed sized header section that somehow, magically adjusts it’s width without stretching. So Section 2 and 8 have to be designed so they can be stretched horizontally while section 4 and 6 need to be designed so they can stretch vertically.

If you really want a fixed sized element, you have to ensure that the element actually has the designed fixed size.

edit

Note that there is the draw mode “tiled” which does not stretch the image sections but rather tiling it. However the image sections need to be designed in a way that tiling makes sense which it doesn’t for your image example.

I know this is an old thread but I came across this while Googling and saw it had no final answer. The answer is this - your pixels per unit multiplier is probably wrong. By default it is “1” but due to how your image looks (stretched) it’s likely its supposed to be a higher number to match how your canvas is set up, probably “100” or something.

Bumping this. At last just tell me that it doesn’t work. And hasn’t for the last 5 years. And that Unity doesn’t give a damn. Cuz, hey, why should anything work

Great job Unity! Really top notch!!!

Hmmm. Answer still too short …

Why don’t think fix this stuff? Are they afraid that fixing bugs will break things?

Thanks Bunny, but you can clearly see that the top 3 sections are all being scaled vertically and are taller than their respective sections in the sprite. Maybe you want to look again at what I am doing as I think it’s pretty clear from the images I posted.

This is a bug in Unity. Apparently half a decade old. And a really dumb one. That many have complained about. For years.