1
0
mirror of https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git synced 2025-01-22 23:28:28 -05:00
UDRIGEEKCup2024/Assets/GolfControls/UI/PowerBarDisplay.cs

30 lines
713 B
C#

using System;
using UnityAtoms.BaseAtoms;
using UnityEngine;
namespace GolfControls
{
public class PowerBarDisplay : MonoBehaviour
{
public FloatVariable powerVariable;
[SerializeField]private RectTransform maskRect;
[SerializeField]private RectTransform fillingRect;
private void Update()
{
UpdateDisplay(powerVariable.Value);
}
private void UpdateDisplay(float percent)
{
float width = maskRect.sizeDelta.x;
float maxHeight = fillingRect.sizeDelta.y;
float scaledHeight = maxHeight * percent;
maskRect.sizeDelta = new Vector2(width,scaledHeight);
}
}
}