using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class LoadingPf : PFUIPanel { List sprites; Image image; protected override void Awake() { base.Awake(); sprites = new List(); for (int i = 1; i < 80; i++) { #if UNITY_IOS || UNITY_ANDROID sprites.Add(Resources.Load($"Images/loading/loading20{i.ToString("000")}")); #else sprites.Add(Resources.Load($"Images/全屏loading/loading{i.ToString("0000")}")); #endif } image = transform.GetComponent(); } protected override void Start() { } int index = 0; //float time = 0; public override void Show() { base.Show(); index = 0; //time = 0; StartCoroutine(Animation()); } IEnumerator Animation() { for (; ; ) { if (index % 79 == 0) { index = 0; } image.sprite = sprites[index]; index++; yield return new WaitForSeconds(0.03f); } } void Update() { //time += Time.deltaTime; //if (time < 0.03) //{ // return; //} //time = 0; //if (index % 79 == 0) //{ // index = 0; //} //image.sprite = sprites[index]; //index++; } public override void Close() { StopCoroutine(Animation()); base.Close(); } }