To display multiple pickups of different objects as text totals via a dynamic Dictionary, follow these steps:
- Replace the content of the PickUp script class with the following code:
using UnityEngine;
public class PickUp : MonoBehaviour
{ public enum PickUpType { Star, Key, Heart }
public PickUpType type; }
- Remove the instance of the PlayerInventory script class from the player-SpaceGirl GameObject.
- Create a new C# script class called PlayerController containing the following code, and add an instance as a component of the player-girl1 GameObject:
using UnityEngine; public class PlayerController : MonoBehaviour { private InventoryManager inventoryManager; void Awake() { inventoryManager = GetComponent<InventoryManager>(); } void OnTriggerEnter2D(Collider2D hit) { if(hit.CompareTag("Pickup")){
PickUp item = hit.GetComponent<PickUp> ();
inventoryManager...