48 lines
671 B
C#
48 lines
671 B
C#
using UIWidgets;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace UIWidgetsSamples
|
|
{
|
|
[RequireComponent(typeof(Button))]
|
|
public class SampleProgressBar2 : MonoBehaviour
|
|
{
|
|
public Progressbar bar;
|
|
|
|
private Button button;
|
|
|
|
private void Start()
|
|
{
|
|
button = GetComponent<Button>();
|
|
if (button != null)
|
|
{
|
|
button.onClick.AddListener(Click);
|
|
}
|
|
}
|
|
|
|
private void Click()
|
|
{
|
|
if (bar.IsAnimationRun)
|
|
{
|
|
bar.Stop();
|
|
}
|
|
else if (bar.Value == 0)
|
|
{
|
|
bar.Animate(bar.Max);
|
|
}
|
|
else
|
|
{
|
|
bar.Animate(0);
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (button != null)
|
|
{
|
|
button.onClick.RemoveListener(Click);
|
|
}
|
|
}
|
|
}
|
|
}
|