74 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LoadingPf : PFUIPanel
{
List<Sprite> sprites;
Image image;
protected override void Awake()
{
base.Awake();
sprites = new List<Sprite>();
for (int i = 1; i < 80; i++)
{
sprites.Add(Resources.Load<Sprite>($"Images/全屏loading/loading{i.ToString("0000")}"));
}
image = transform.GetComponent<Image>();
}
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();
}
}