44 lines
606 B
C#
44 lines
606 B
C#
using UIWidgets;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace UIWidgetsSamples
|
|
{
|
|
[RequireComponent(typeof(Button))]
|
|
public class SampleProgressBar1 : 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
|
|
{
|
|
bar.Animate();
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (button != null)
|
|
{
|
|
button.onClick.RemoveListener(Click);
|
|
}
|
|
}
|
|
}
|
|
}
|