- Home /
How to resize an image by stretching only the center part
Hi all, I'm looking to have a variable-sized experience bar to represent character stats. Each stat, however, has a different maximum value, and I want the size of my experience bar to reflect the max. My experience bar looks like the following:
However, if I attempt to re-size it, the sides become distorted because the image is being stretched or shrunk, so a larger version would look like this:
The only solution I've been able to come up with is separating the image into three components: the the left corner, the center region, and the right corner, and then resizing only the center component and moving the right one based on the size of the center. This is adding a lot of overhead, however, and means that for a single character's stats page, my script has to re-size and re-position about 20 images which is both redundant and inefficient. Does Unity have some other way of dealing with this issue?
Answer by m0guz · Jun 06, 2018 at 11:23 PM
Unity supports 9-sliced sprites. For that bar, slice only from left and right.
Your answer
Follow this Question
Related Questions
Shoot accuracy bar 1 Answer
Question about an inventory system idea 2 Answers
Unity UI constant physical size one image 0 Answers
Turn Another UI image on and off with a Single UI Button 1 Answer
Is there a way to use the prefab image unity shows? 0 Answers