Lets say we have a narrative game , for that we need to have different sizes of dialog box . But we can achieve this using only one Dialog box image .Good thing that Unity’s UI supports 9 Slice Images by Default (Image)
Lets say we have above dialog box sprite.
1. Right click –> UI –> Image and assign your dialog box image to it.
See when we scales the box , the the glow effect stretches and corners are not preserved . If we want to preserve the corners , we will make the image 9 Sliced .How to create 9 Slice Image :
unity 9 slice image,unity ui tutorial,unity sprite editor , learn unity1. Click on the image you want to 9 Slice and Set the Texture type to Sprite and click on Sprite Editor
Now you can resize the dialog box to any size , the glow and the corners will be preserved.
How 9 Slice sprite works –
In 9 slice the sprite is divided into 9 parts (virtually) .
|1,3,7,9||Does not scale|
|4,6||Scales vertically only|
|2,8||Scales horizontally only|
|5||Scales horizontally and vertically|