Advertisement
JonneOpettaja

Level.cs

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