Fix Stretched UI in Unity (9-Slice Explained)
If your UI elements in Unity start looking stretched when you resize them, you probably ran into one of the most common beginner problems. You make a button or a panel, scale it up, and suddenly the corners look wrong and everything feels distorted.
This happens because Unity stretches sprites by default. It treats them like normal images, so when you change the size, every part of the sprite gets scaled equally. That works fine for photos, but not for UI.
Here’s what that looks like:
The fix for this is something called 9-slice.
If you prefer seeing it first, here’s a quick video that shows the problem and the fix:
9-slice is a way to tell Unity which parts of your sprite should stay the same and which parts are allowed to stretch. The corners stay untouched, the edges stretch only in one direction, and the center fills the rest. That’s why buttons and panels can scale without breaking visually.
To fix your UI, go to your sprite in the Project window and select it. In the Inspector, make sure the texture type is set to Sprite (2D and UI). Then open the Sprite Editor.
Inside the Sprite Editor, you’ll see green lines around your sprite. These define the borders. Drag them inward slightly so that the corners of your sprite are inside those borders. These corner areas will no longer stretch.
Apply the changes and go back to your UI element. In the Image component, change the Image Type from “Simple” to “Sliced”.
Now when you resize the UI element, the corners should stay clean and the edges will stretch properly.
If it still looks wrong, it’s usually something small. Either the borders weren’t set correctly, the changes weren’t applied, or the Image Type is still set to Simple.
If it still looks wrong, it’s usually something small. Either the borders weren’t set correctly, the changes weren’t applied, or the Image Type is still set to Simple.


Comments
Post a Comment