maxhacker11

CollectiblesManager.cs

Dec 3rd, 2023
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | Source Code | 0 0
  1. using UnityEngine;
  2. using TMPro;
  3.  
  4. public class CollectiblesManager : MonoBehaviour
  5. {
  6.     public TextMeshProUGUI gemUI;
  7.     int numGemsCollected = 0;
  8.  
  9.     // Example of another collectible type
  10.     //public TextMeshProUGUI diamondUI;
  11.     //int numDiamondsCollected = 0;
  12.  
  13.     private void OnEnable()
  14.     {
  15.         Gem.OnGemCollected += GemCollected;
  16.         //Diamond.OnDiamondCollected += DiamondCollected;
  17.     }
  18.  
  19.     private void OnDisable()
  20.     {
  21.         Gem.OnGemCollected -= GemCollected;
  22.         //Diamond.OnDiamondCollected -= DiamondCollected;
  23.     }
  24.  
  25.     private void GemCollected()
  26.     {
  27.         numGemsCollected++;
  28.         gemUI.text = numGemsCollected.ToString();
  29.     }
  30.  
  31.     //private void DiamondCollected()
  32.     //{
  33.     //    numDiamondsCollected++;
  34.     //    diamondUI.text = numDiamondsCollected.ToString();
  35.     //}
  36. }
  37.  
Tags: COLLECTIBLES
Advertisement
Add Comment
Please, Sign In to add comment