Advertisement
Munchy2007

Unet5Tut5Pt2HUD

Feb 24th, 2016
4,615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. public class HUD : MonoBehaviour {
  6.     public static HUD instance;
  7.     Text healthText;
  8.  
  9.     void Awake () {
  10.         if(instance == null)
  11.         {
  12.             instance = this;
  13.             healthText = transform.Find("HealthText").GetComponent<Text>();
  14.             GetComponentInChildren<Camera>().gameObject.SetActive(false);
  15.         }
  16.         else
  17.         {
  18.             DestroyImmediate(gameObject);
  19.             return;
  20.         }
  21.     }
  22.  
  23.     public void DisplayHealth(int health)
  24.     {
  25.         healthText.text = string.Format("Health: {0}", health);
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement