u3d changeTexs
using UnityEngine; using System.Collections; using System.Collections.Generic; public class CTex : MonoBehaviour { public List<Texture2D> tx1; public int mfps; private float m_OldTime; private float m_DelTime; private int m_NowTex; // Use this for initialization void Start () { m_DelTime = 1.0f / mfps; m_OldTime = Time.time; m_NowTex = 0; } // Update is called once per frame void Update () { float NowTime = Time.time; // Debug.Log("Time.time:"+ NowTime); if (NowTime - m_OldTime >m_DelTime) { Debug.Log("NowTex:"+ m_NowTex); this.renderer.material.mainTexture = tx1[m_NowTex]; m_NowTex++; m_OldTime = NowTime; if (m_NowTex >= tx1.Count) m_NowTex = 0; } } }
list是要播放的图片序列,mfps是帧率,越大图片播放的越快,越小越慢
Time.time得到的是游戏开始运行到现在的运行时间长度,单位是秒