In the previous recipe, we started to work with UI panels and images to create a more general-purpose GameObject for displaying inventory slots, as well as images to indicate what is stored in them. In this recipe, we will take things a little further with the graphics and also create a C# script class that works with each inventory slot object:
Figure 3.22 – Example showing two items, each with three slots
As shown in the preceding screenshot, in this recipe, we'll create a UI (and scripts) for an inventory that has three locations for stars, and three more for keys, using colored and gray icons to indicate how many have been collected.