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.
48 lines
689 B
48 lines
689 B
using UnityEngine; |
|
using UnityEngine.UI; |
|
using UIWidgets; |
|
|
|
namespace UIWidgetsSamples { |
|
[RequireComponent(typeof(Button))] |
|
public class SampleProgressBar2 : MonoBehaviour { |
|
public Progressbar bar; |
|
|
|
Button button; |
|
// Use this for initialization |
|
void Start() |
|
{ |
|
button = GetComponent<Button>(); |
|
if (button!=null) |
|
{ |
|
button.onClick.AddListener(Click); |
|
} |
|
} |
|
|
|
void Click() |
|
{ |
|
if (bar.IsAnimationRun) |
|
{ |
|
bar.Stop(); |
|
} |
|
else |
|
{ |
|
if (bar.Value==0) |
|
{ |
|
bar.Animate(bar.Max); |
|
} |
|
else |
|
{ |
|
bar.Animate(0); |
|
} |
|
} |
|
} |
|
|
|
void OnDestroy() |
|
{ |
|
if (button!=null) |
|
{ |
|
button.onClick.RemoveListener(Click); |
|
} |
|
} |
|
} |
|
} |