The PlayerInventory script class

The playerInventoryDisplay variable is a reference to an instance object of class PlayerInventoryDisplay.

The bool variable carryingStar represents whether or not the player is carrying the star at any point in time; it is initialized to false.

Method Awake() caches a reference to the sibling component playerInventoryDisplay.

When the scene begins, via the Start() method, we call the OnChangeCarryingStar(...) method of script component playerInventoryDisplay, passing in the initial value of carryingStar (which is false). This ensures that we are not relying on text typed into the UI Text object Text-carrying-star at Design-Time, so that the UI seen by the user is always set by our Run-Time methods. This avoids ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.