36 lines
705 B
C#
36 lines
705 B
C#
using System.Collections.Generic;
|
|
using Obvious.Soap;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UI_GearDamageIndicator : MonoBehaviour
|
|
{
|
|
public FloatVariable LineTension;
|
|
|
|
public FloatVariable MaxGearStrength;
|
|
|
|
[SerializeField]
|
|
private List<Image> fillImages;
|
|
|
|
[SerializeField]
|
|
private Color damageColor;
|
|
|
|
private void OnEnable()
|
|
{
|
|
LineTension.OnValueChanged += OnLineTension;
|
|
}
|
|
|
|
private void OnLineTension(float value)
|
|
{
|
|
foreach (Image fillImage in fillImages)
|
|
{
|
|
fillImage.color = Color.Lerp(t: fillImage.fillAmount = value / MaxGearStrength.Value, a: Color.white, b: damageColor);
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
LineTension.OnValueChanged -= OnLineTension;
|
|
}
|
|
}
|