34 lines
465 B
C#
34 lines
465 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ControllBar : MonoBehaviour
|
|
{
|
|
public Image[] bars;
|
|
|
|
[Range(-1f, 1f)]
|
|
public float value;
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (value > 0f)
|
|
{
|
|
bars[1].fillAmount = value;
|
|
bars[0].fillAmount = 0f;
|
|
}
|
|
else if (value < 0f)
|
|
{
|
|
bars[0].fillAmount = Mathf.Abs(value);
|
|
bars[1].fillAmount = 0f;
|
|
}
|
|
else
|
|
{
|
|
bars[0].fillAmount = 0f;
|
|
bars[1].fillAmount = 0f;
|
|
}
|
|
}
|
|
}
|