mirror of
https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git
synced 2025-01-22 15:18:25 -05:00
30 lines
713 B
C#
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);
|
|
}
|
|
}
|
|
}
|