Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class CaloriesBar : MonoBehaviour
- {
- private Slider slider;
- public Text caloriesCounter;
- public GameObject playerState;
- private float currentCalories, maxCalories;
- void Awake()
- {
- slider = GetComponent<Slider>();
- }
- void Update()
- {
- currentCalories = playerState.GetComponent<PlayerState>().currentCalories;
- maxCalories = playerState.GetComponent<PlayerState>().maxCalories;
- float fillValue = currentCalories / maxCalories; // 100/100
- slider.value = fillValue;
- caloriesCounter.text = currentCalories + "/" + maxCalories;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement