Book Image

NGUI for Unity

By : Charles Bernardoff
Book Image

NGUI for Unity

By: Charles Bernardoff

Overview of this book

Table of Contents (14 chapters)


We have created our first sprite and understood how to move, rotate, and change its dimensions. We actually scaled it up massively compared to its original size. But this 15 x 15 sprite has something special.

If you select the Sprite (Dark) GameObject, you will see it has four dotted lines inside the Preview window in the Inspector view. This means it's a sliced sprite:

Sliced sprites

A sliced sprite is an image divided in nine sections, making it resizable while conserving its corners' proportions. Sliced sprites may be scaled as you wish—they still look beautiful.

Since Sprite (Dark) is a 9-slice sprite, we must tell our UISprite component to treat it as such. Perform the following steps to do so:

  1. Select the Sprite (Dark) GameObject.

  2. Click on the drop-down menu next to its Sprite Type field.

  3. Select Sliced.

Notice how the sprite looks good now—it's not stretched anymore!


The Fill Center parameter allows you to only show the sprite's borders and leave only transparency inside.

Even though...