Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(196评价)
价格: 4049.00元
Unity3d读取帧序列帧发布出来出现闪屏
独一无二发起了问答2019-01-22
2
回复
819
浏览
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读取序列帧,几百张的时候还是正常的,到了几千张的时候,发布出来就出现闪屏,编译器里面运行一直都很正常

所有回复
  • 老师_Trigger 2019-01-22

    同学你好,可以看一下这两篇文章:

    https://blog.csdn.net/puremilk684/article/details/51471956

    https://blog.csdn.net/jiguangcanhen/article/details/41449003

    如果还是不行,就把所有图片加载读取完毕之后再去使用,不要边加载边设置。

    还有-5条回复,点击查看
    你还没有登录,请先登录注册
  • 独一无二 2019-01-23

    嗯  我尝试过把他先加载到内存,之后在进行使用,发布出来Pc,加载完毕还是出现闪屏。

    还有-5条回复,点击查看
    你还没有登录,请先登录注册
发表回复
你还没有登录,请先 登录或 注册!