using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class JDLoad : MonoBehaviour { public GameObject tip; public GameObject canvas; public JDTLoad jdt; public Text jd1; public Text jd2; public Text StateInfo; public Image img; public Button btn; private int id = 0; private void Awake() { StartCoroutine(Load()); btn.onClick.AddListener(() => { tip.SetActive(true); jdt.Load(); canvas.SetActive(false); }); } IEnumerator Load() { while (id < 100) { float t = (float)8 / 100; yield return new WaitForSeconds(t); id++; jd1.text = id.ToString(); jd2.text = id.ToString(); img.fillAmount = (float)id / 100; if (id >= 80) { StateInfo.text = "检测到问题"; } } btn.gameObject.SetActive(true); } }