Advertisement
CakeMeister

HeartUI phan 8

Jun 30th, 2017
1,728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class HeartUI : MonoBehaviour {
  7.     public Sprite[] Heartsprite;
  8.  
  9.     public Player player;
  10.  
  11.     public Image Heart;
  12.  
  13.     // Use this for initialization
  14.     void Start () {
  15.         player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
  16.     }
  17.    
  18.     // Update is called once per frame
  19.     void Update () {
  20.         if (player.ourHealth > 5)
  21.             player.ourHealth = 5;
  22.  
  23.  
  24.         if (player.ourHealth < 0)
  25.             player.ourHealth = 0;
  26.  
  27.         Heart.sprite = Heartsprite[player.ourHealth];
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement