图片序列帧的实现

1.申明变量;

    private List logoList = new List();

    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().texture = logoList[indexLogoNum];

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

        }

    }

你可能感兴趣的:(图片序列帧的实现)