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.
40 lines
1.2 KiB
40 lines
1.2 KiB
using UnityEngine; |
|
using System.Collections; |
|
using UnityEngine.UI; |
|
|
|
public class SliderProgress : MonoBehaviour { |
|
float currentAmount = 0; |
|
public float targetProcess = 100; |
|
float speed = 0.1f; |
|
public GameObject Slider; |
|
private Text m_text; |
|
public Button OK; |
|
// Use this for initialization |
|
void Start () { |
|
m_text = transform.Find("ProgressReport").gameObject.GetComponent<Text>(); |
|
} |
|
|
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
//Fix me...... |
|
if (currentAmount < targetProcess && m_text.text!=null) |
|
{ |
|
//Debug.Log("currentAmount:" + currentAmout.ToString()); |
|
currentAmount += speed; |
|
if (currentAmount > targetProcess) |
|
currentAmount = targetProcess; |
|
|
|
m_text.text= m_text.text.Substring(0,3) + ((int)currentAmount).ToString() + "%"; |
|
Slider.GetComponent<Slider>().value = currentAmount / 100.0f; |
|
} |
|
else { |
|
m_text.text = m_text.text.Substring(1, 3) + "完毕,请关闭窗口!"; |
|
OK.gameObject.SetActive(true); |
|
OK.onClick.AddListener(delegate () |
|
{ |
|
Destroy(gameObject); |
|
}); |
|
} |
|
} |
|
}
|
|
|