Four UI Image objects, Image-star0/1/2/3, have been created at the top of the screen and initialized with the gray placeholder icon. The gray and yellow icon sprite files have been resized to be 100 x 100 pixels, which makes positioning them at design time easier, since their positions are (0,0), (100,0), (200,0), and (300,0). In a more complicated game screen or one where screen real estate is precious, the actual size of the icons would probably be smaller – a decision to be made by the game UI designer.
In the PlayerInventory script class, the totalStars int variable represents how many stars have been collected so far; it is initialized to zero. The playerInventoryDisplay variable is a reference to the scripted component that manages our inventory display – this variable is cached before the scene begins in the Awake() method.
The Start() method that runs at the beginning of the scene calls the OnChangeStarTotal(......