You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
573 B
41 lines
573 B
2 years ago
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using UIWidgets;
|
||
|
|
||
|
namespace UIWidgetsSamples {
|
||
|
[RequireComponent(typeof(Button))]
|
||
|
public class SampleProgressBar1 : MonoBehaviour {
|
||
|
public Progressbar bar;
|
||
|
|
||
|
Button button;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
button = GetComponent<Button>();
|
||
|
if (button!=null)
|
||
|
{
|
||
|
button.onClick.AddListener(Click);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Click()
|
||
|
{
|
||
|
if (bar.IsAnimationRun)
|
||
|
{
|
||
|
bar.Stop();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
bar.Animate();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
if (button!=null)
|
||
|
{
|
||
|
button.onClick.RemoveListener(Click);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|