mirror of
				https://github.com/DerTyp7/example-top-down-unity.git
				synced 2025-10-31 21:27:07 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			658 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			658 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.UI;
 | |
| 
 | |
| public class VitalityUI : MonoBehaviour
 | |
| {
 | |
|     Vitality playerVitality;
 | |
| 
 | |
|     [SerializeField]
 | |
|     Image healthBar;
 | |
| 
 | |
|     [SerializeField]
 | |
|     Image foodBar;
 | |
| 
 | |
|     [SerializeField]
 | |
|     Image drinkBar;
 | |
| 
 | |
| 
 | |
|     private void Start()
 | |
|     {
 | |
|         TimeManager.OnTimeInterval += UpdateBars;
 | |
|         playerVitality = GameObject.Find("Player").GetComponent<Vitality>();
 | |
|     }
 | |
| 
 | |
|     void UpdateBars()
 | |
|     {
 | |
|         healthBar.fillAmount = playerVitality.health;
 | |
|         foodBar.fillAmount = playerVitality.food;
 | |
|         drinkBar.fillAmount = playerVitality.drink;
 | |
|     }
 | |
| }
 | 
