How to do it...

To display inventory total text for multiple pickups of different object types, follow these steps:

  1. Start with a new copy of the Simple2Dgame_SpaceGirl mini-game.
  2. Edit the tags, changing Star to Pickup. Ensure that the star GameObject now has the Pickup tag.
  1. Add the following C# Script PickUp to the GameObject star in the Hierarchy:
using UnityEngine; 
using System.Collections; 

public class PickUp : MonoBehaviour { 
  public string description; 
}
  1. In the Inspector, change the description property of component Pick Up (Script) of GameObject star to the text star:
  1. Select the GameObject star in the Hierarchy panel and make ...

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.