1 using UnityEngine; 2 using System.Collections; 3 4 public class Bird : MonoBehaviour { 5 6 public float timer = 0; 7 public int freamNumber = 10; //每秒播放的帧数 帧速率 8 public int freamCount = 0; //帧数 9 private Renderer rend; 10 // Use this for initialization 11 void Start () { 12 rend =GetComponent <Renderer >(); 13 } 14 15 // Update is called once per frame 16 void Update () { 17 timer += Time.deltaTime; //时间自增 18 //Debug.Log(timer); 19 if (timer >= 1.0f / freamNumber) { 20 freamCount++; 21 timer -= 1.0f / freamNumber; 22 int freamIndex = freamCount % 3; 23 rend .material .SetTextureOffset ("_MainTex",new Vector2 (0.333f*freamIndex ,0)); 24 //Debug.Log(freamCount); 25 } 26 } 27 }
时间: 2024-10-06 23:47:34