美文网首页
图片序列帧的实现

图片序列帧的实现

作者: 不过一书生 | 来源:发表于2019-04-22 15:13 被阅读0次

    1.申明变量;

        private List<Texture> logoList = new List<Texture>();

        private float timer = 0.3f;

        private int indexLogoNum = 0;

    2.加载图片;此处最好用协程;

    for (int i = 0; i < 235; i++)//235,看个人需求

            {

                string path = "logo/logo-+_" + (265 + i).ToString().PadLeft(5,'0');//Resources文件夹下的路径,末尾一般是数据,0补齐.例如:00031;

                Texture tex = Resources.Load(path) as Texture;

                logoList.Add(tex);//加入到申明的数据列表

            }

    3.展示图片,控制时间间隔,达到最好的效果;

    void Update ()//此处展示的是循环播放,如有特殊需要,视情况而定

        {

            timer -= Time.deltaTime;

            if(timer<0)

            {

                indexLogoNum += 1;

                if (indexLogoNum > (logoList.Count - 1))

                {

                    indexLogoNum = 1;

                }

                transform.GetComponent<RawImage>().texture = logoList[indexLogoNum];

    //transform.GetComponent<MeshRenderer>().material.mainTexture = logoList[indexLogoNum];//天空球的贴图更换

            }

        }

    相关文章

      网友评论

          本文标题:图片序列帧的实现

          本文链接:https://www.haomeiwen.com/subject/qcwygqtx.html