using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class playImage : MonoBehaviour {
private Image image;
private Sprite loadImage;
public string path = "";
public Sprite screen;
public float speed = 0.025f;
// public GameObject ETLY_Bt;
void Start()
{
image = GetComponent<Image>();
image.sprite = screen;
// ETLY_Bt.SetActive(false);
fanQingQI();
}
public void fanQingQI()
{
StartCoroutine(PlayAnmator());
}
private IEnumerator PlayAnmator()
{
int num = 0;
while (Resources.Load<Sprite>(MatchingStr(num)) != null)
{
loadImage = Resources.Load<Sprite>(MatchingStr(num));
yield return loadImage;
image.sprite = loadImage;
num++;
yield return new WaitForSeconds(speed);
}
Debug.Log(num);
}
private string MatchingStr(int num)
{
string str = "";
if (num < 10)
{
str = path + "0000" + num;
}
else
{
if (num < 100)
{
str = path + "000" + num;
}
else
{
str = path + "00" + num;
}
}
num = 0;
//str = path + num;
return str;
}
}
unity3d读取序列帧,几百张的时候还是正常的,到了几千张的时候,发布出来就出现闪屏,编译器里面运行一直都很正常
同学你好,可以看一下这两篇文章:
https://blog.csdn.net/puremilk684/article/details/51471956
https://blog.csdn.net/jiguangcanhen/article/details/41449003
如果还是不行,就把所有图片加载读取完毕之后再去使用,不要边加载边设置。