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中播放序列帧动画
本文详细介绍了在Unity3D中如何播放序列帧动画,涵盖了从导入图片序列到设置动画组件的完整步骤,适合初学者和3D游戏开发者参考。
摘要由CSDN通过智能技术生成