Revealing icons for multiple object pickups by changing the size of a tiled image

Another approach that could be taken to show increasing numbers of images is to make use of tiled images. The same visual effect as in the previous recipe can also be achieved by making use of a tiled gray star image of width 400 (showing four copies of the gray star icon), behind a tiled yellow star image, whose width is 100 times the number of stars collected.

If the yellow-starred image is less wide that the gray starred imaged beneath then we'll see gray stars for any remaining locations. For example, if we are carrying 3 stars, we'll make the width of the yellow-starred image 3 x 100 = 300 pixels wide. This will show 3 yellow stars and reveal 100 pixels, ...

Get Unity 2018 Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.