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:
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:
Notice how the sprite looks good now—it's not stretched anymore!
A tiling sprite is a pattern meant to be repeated indefinitely—it can be used to cover a large surface by repeating the same texture. Let's try it right now:
Window
.0
, 0
, 0
} position and has a scale of {1
, 1
, 1
}.0
.115
, G to 240
, B to 255
, and A to 255
.Ok, we have our window. Let's create a tiled background to make it look better by performing the following steps:
Background
.1
.115
, G to 240
, B to 255
, and A to 255
.That looks better! We now have a tiling sprite for our window's background, and it looks as follows:
We used the UIStretch component to avoid setting dimensions manually; if you change the window's Dimensions, the background will resize itself automatically.
The UIAnchor component is used to make sure the background also moves with the window.
A filled sprite is useful to create life bars or progress bars; with this, you can set a sprite and change the Fill Amount parameter between 0 and 1 to hide a part of it. The following screenshot shows a partially hidden progress bar:
Let's create this effect with the following steps:
Move the Fill Amount slider and you can see what it does on the game view. You've understood the filled sprite system. Now set the Sprite Type field back to Tiled.
Ok, we've seen different sprite widgets and parameters. Let's learn how to add text.
18.118.137.7