How to keep sprite borders the same size when scaling a sprite in Unity?

I created an image in Photoshop to use as a sprite in Unity, and everything works fine as long as the sprite is scaled to X: 1; Y: 1.

The problem starts when I scale the image up when the border of the image stretches with the rest of the image. Is there a way to scale the image from its center, or ignore the border of the image when scaling?

Here's an example I can show:

enter image description here

The rectangle on top is the original image without scaling or downsizing, and the rectangle on the bottom is scaled in X: 5, Y: 0.5, but the borders are stretched.

I think the borders are stretched because part of the image and when it is scaled, the image (including the borders) is just stretched.

Is there a way to stretch the sprite image but ignore the borders?

+3


source to share


2 answers


Are you trying to scale the image and keep the original ratio?

If so, follow these steps:



enter image description here

Hope this helps. Please let me know if you are trying to do something else.

+1


source


You can use a sliced ​​sprite. The center of the image is scaled to fit the control rectangle, but the borders remain sized regardless of scaling. Check out the Unity doc here: Unity - Manual: Image



+1


source







All Articles