public int AddClip(string name, float start, float end, MegaRepeatMode loop) { MegaMorphAnimClip clip = new MegaMorphAnimClip(name, start, end, loop); clips.Add(clip); return(clips.Count - 1); }
public int AddClip(string name, float start, float end, MegaRepeatMode loop) { MegaMorphAnimClip clip = new MegaMorphAnimClip(name, start, end, loop); clips.Add(clip); return clips.Count - 1; }
public void UpdatePlayingClips() { if (playing.Count == 0) { return; } // reset blends morph.ClearBlends(); for (int i = playing.Count - 1; i >= 0; i--) { MegaPlayingClip pclip = playing[i]; MegaMorphAnimClip clip = clips[pclip.clipIndex]; if (pclip.t >= 0.0f) { pclip.t += Time.deltaTime * clip.speed; float dt = clip.end - clip.start; switch (clip.loop) { case MegaRepeatMode.Loop: pclip.at = Mathf.Repeat(pclip.t, dt); break; case MegaRepeatMode.PingPong: pclip.at = Mathf.PingPong(pclip.t, dt); break; case MegaRepeatMode.Clamp: pclip.at = Mathf.Clamp(pclip.t, 0.0f, dt); break; } pclip.at += clip.start; if (pclip.targetblendtime != 0.0f) { if (pclip.targetblendtime > 0.0f) { pclip.blendtime += Time.deltaTime; if (pclip.blendtime >= pclip.targetblendtime) { pclip.targetblendtime = 0.0f; pclip.weight = 1.0f; } else { pclip.weight = (pclip.targetblendtime - pclip.blendtime) / pclip.targetblendtime; } } else { pclip.blendtime -= Time.deltaTime; if (pclip.blendtime <= pclip.targetblendtime) { pclip.targetblendtime = 0.0f; pclip.weight = 0.0f; } else { pclip.weight = (pclip.targetblendtime - pclip.blendtime) / pclip.targetblendtime; } } } if (pclip.weight != 0.0f) { if (MultipleMorphs) { if (morphs != null) { for (int m = 0; m < morphs.Length; m++) { morphs[m].SetAnimBlend(pclip.at, pclip.weight); } } } else { if (morph) { morph.SetAnimBlend(pclip.at, pclip.weight); } } } else { PushClip(pclip); playing.RemoveAt(i); } } } }