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 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.