JonneOpettaja

LevelSimple

Mar 8th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Level : MonoBehaviour {
  6.  
  7.     int numTreasures;
  8.     int collected = 0;
  9.  
  10.     // Use this for initialization
  11.     void Start () {
  12.         GameObject[] treasureObjects = GameObject.FindGameObjectsWithTag("Treasure");
  13.         numTreasures = treasureObjects.Length;
  14.     }
  15.  
  16.     void TreasureCollected()
  17.     {
  18.         collected++;
  19.     }
  20.  
  21.     void OnGUI()
  22.     {
  23.         GUI.skin.label.fontSize = 20;
  24.         GUI.Label(new Rect(10, 40, 200, 30), "Treasures: " + collected + "/" + numTreasures);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment