public void TestAnim(AnimClipKeyData animkey) { animator = this.gameObject.GetComponentInChildren <Animator>(); if (animator == null) { return; } animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; animator.SetInteger(animkey.AnimclipName, animkey.ParamValue); CurClipData = animkey; CurClipFrameNum = 0; CurRunningTime = 0; }
public void Update() { if (CurClipData == null) { return; } CurRunningTime += (int)(Time.deltaTime * 1000); while (CurClipData.GetFrameTime(CurClipFrameNum) <= CurRunningTime) { Run(); CurClipFrameNum++; } if (CurRunningTime >= CurClipData.Length) { CurClipData = null; } }
void ExportAnim(AnimationClip animclip, ACTAnimConfig animcfg) { if (animclip == null) { return; } maxcounter = (int)(animclip.length / (1f / 30f) + 0.5f) + 1; int[] xs = new int[maxcounter]; int[] ys = new int[maxcounter]; int[] zs = new int[maxcounter]; foreach (EditorCurveBinding theCurveBinding in AnimationUtility.GetCurveBindings(animclip)) { string name = theCurveBinding.propertyName.ToLower(); //Debug.Log("************** " + theCurveBinding.path + " : " + name); if (theCurveBinding.path == MoveNodeName && name.Contains("position")) { Debug.Log("************** " + theCurveBinding.path + " : " + name); AnimationCurve testcurve = AnimationUtility.GetEditorCurve(animclip, theCurveBinding); if (name.Contains(".x")) { ExportKeyData(ref xs, testcurve); } else if (name.Contains(".y")) { //ExportKeyData(ref ys, testcurve); } else if (name.Contains(".z")) { ExportKeyData(ref zs, testcurve); } //hasposition = true; if (!name.Contains(".y")) { AnimationUtility.SetEditorCurve(animclip, theCurveBinding, null); } } } AnimClipKeyData data = new AnimClipKeyData(xs, ys, zs, animclip.name); animcfg.keyDatas.Add(data); }