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); } } }