How to do it...

To create a C# inventory slot display script component, follow these steps:

  1. Import the _Scripts folder from the provided files (this contains a copy of the script class PlayerInventory from one of the previous recipes, which we can use unchanged for this recipe).
  2. Delete two of the three inventory slot GameObjects: Panel-inventory-slot (1) and (2). So, only Panel-inventory-slot remains.
  3. First we'll create a panel for three star slots. In the Hierarchy panel, create a UI Panel (Create | UI | Panel) and rename it Panel-stars.
  4. We'll now position Panel-stars at the top-left of the Game panel, and make it fit within the left side of our general inventory rectangle. Edit the UI Image's Rect Transform component, and while holding ...

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.