public void PlayAnimation(string path, string name, int rate, WrapMode mode, float fSpeed, int iFrameIndex) { this.dummys = ModelAnimation.s_dummy[path + "/" + name]; MeshClip1 meshClips = ModelAnimation.getMeshClips(this.m_ctrl, path + "/" + name); if (meshClips != null) { this.PlayAnimation(meshClips, rate, mode, fSpeed, iFrameIndex); } }
public static MeshClip1 getMeshClips(AnimPlayer ctrl, string name) { if (ModelAnimation.s_mapMeshCenter.ContainsKey(name)) { Dictionary <string, List <Mesh> > dictionary = ModelAnimation.s_mapMeshCenter[name]; MeshClip1 meshClip = new MeshClip1(); string text = ctrl.meshanim[0].name; text = text.Substring(0, text.Length - 1); if (ctrl.meshanim != null && dictionary.ContainsKey(text)) { meshClip.m_MeshFrames = dictionary[text]; return(meshClip); } } return(null); }
private void PlayAnimation(MeshClip1 clip, int frameRate, WrapMode mode, float speed, int iFrameIndex) { if (null == this.m_MeshFilter) { this.m_MeshFilter = base.gameObject.GetComponent <MeshFilter>(); } this.m_AnimaitonClip = clip; this.m_WarpMode = mode; this.m_iFrameRate = frameRate; this.m_fSpeed = speed; this.m_fStartTime = 0f; this.m_fNextFrameTime = 0f; this.m_bIncrease = true; this.m_iCurrentFrame = iFrameIndex; if (this.m_iCurrentFrame > this.m_AnimaitonClip.m_MeshFrames.Count) { this.m_iCurrentFrame = this.m_AnimaitonClip.m_MeshFrames.Count - 1; } this.m_MeshFilter.mesh = this.m_AnimaitonClip.m_MeshFrames[this.m_iCurrentFrame]; }
private void Update() { if (this.m_AnimaitonClip == null) { return; } float num = Time.deltaTime * this.m_fSpeed; if (this.m_WarpMode == WrapMode.Loop) { this.m_fStartTime += num; this.m_fNextFrameTime += num; if (this.m_fNextFrameTime < 1f / (float)this.m_iFrameRate) { return; } this.m_fNextFrameTime = 0f; this.m_iCurrentFrame++; if (this.m_iCurrentFrame >= this.m_AnimaitonClip.GetFrameCount()) { this.m_iCurrentFrame = 0; } this.SetCurrentFrame(); } else if (this.m_WarpMode == WrapMode.PingPong) { this.m_fStartTime += num; this.m_fNextFrameTime += num; if (this.m_fNextFrameTime < 1f / (float)this.m_iFrameRate) { return; } this.m_fNextFrameTime = 0f; if (this.m_bIncrease) { this.m_iCurrentFrame++; if (this.m_iCurrentFrame == this.m_AnimaitonClip.GetFrameCount() - 1) { this.m_bIncrease = false; } } else { this.m_iCurrentFrame--; if (this.m_iCurrentFrame == 0) { this.m_bIncrease = true; } } if (this.m_iCurrentFrame >= this.m_AnimaitonClip.GetFrameCount()) { this.m_iCurrentFrame = 0; } this.SetCurrentFrame(); } else if (this.m_WarpMode == WrapMode.ClampForever) { this.m_fStartTime += num; if (this.m_iCurrentFrame < this.m_AnimaitonClip.GetFrameCount() - 1) { this.m_fNextFrameTime += num; if (this.m_fNextFrameTime < 1f / (float)this.m_iFrameRate) { return; } this.m_fNextFrameTime = 0f; this.m_iCurrentFrame++; this.SetCurrentFrame(); } } else if (this.m_WarpMode == WrapMode.Once) { this.m_fStartTime += num; if (this.m_iCurrentFrame < this.m_AnimaitonClip.GetFrameCount() - 1) { this.m_fNextFrameTime += num; if (this.m_fNextFrameTime < 1f / (float)this.m_iFrameRate) { return; } this.m_fNextFrameTime = 0f; this.m_iCurrentFrame++; this.SetCurrentFrame(); } else { this.m_AnimaitonClip = null; } } else if (this.m_WarpMode == WrapMode.Once) { this.m_fStartTime += num; this.m_fNextFrameTime += num; if (this.m_fNextFrameTime < 1f / (float)this.m_iFrameRate) { return; } this.m_fNextFrameTime = 0f; this.m_iCurrentFrame++; if (this.m_iCurrentFrame >= this.m_AnimaitonClip.GetFrameCount()) { this.m_iCurrentFrame = 0; } this.SetCurrentFrame(); if (this.m_iCurrentFrame == 0) { this.m_AnimaitonClip = null; } } }