class FrameAnimation { private float fps = 10.0f; private Rect drawPos; private float time = 0; private int currentIndex = 0; public void DrawFrameAnimation(Texture[] frameTex) { int length = frameTex.Length; GUI.DrawTexture(drawPos, frameTex[currentIndex]); time += Time.deltaTime; if(time >= 1.0f/fps) { currentIndex++; time = 0; if(currentIndex>= length-1) { currentIndex = length - 1; } } } public FrameAnimation(Rect drawPos,float fps) { this.drawPos = drawPos; this.fps = fps; } } 在unity3D中新建一个脚本直接调用该类。 using UnityEngine; using System.Collections; public class DrawAnimation : MonoBehaviour { //private Resources resource; private Rect drawPos = new Rect(200,0,500,200); private Object[] texObject; |
Unity3D中播放序列帧动画
最新推荐文章于 2024-03-18 09:45:16 发布