static void BakeBone (Bone bone, Spine.Animation animation, AnimationClip clip) { Skeleton skeleton = bone.Skeleton; bool inheritRotation = bone.Data.InheritRotation; skeleton.SetToSetupPose(); animation.Apply(skeleton, 0, 0, true, null); skeleton.UpdateWorldTransform(); float duration = animation.Duration; AnimationCurve curve = new AnimationCurve(); List<Keyframe> keys = new List<Keyframe>(); float rotation = bone.RotationIK; if (!inheritRotation) rotation = GetUninheritedRotation(bone); keys.Add(new Keyframe(0, rotation, 0, 0)); int listIndex = 1; float r = rotation; int steps = Mathf.CeilToInt(duration / bakeIncrement); float currentTime = 0; float lastTime = 0; float angle = rotation; for (int i = 1; i <= steps; i++) { currentTime += bakeIncrement; if (i == steps) currentTime = duration; animation.Apply(skeleton, lastTime, currentTime, true, null); skeleton.UpdateWorldTransform(); int pIndex = listIndex - 1; Keyframe pk = keys[pIndex]; pk = keys[pIndex]; if (inheritRotation) rotation = bone.RotationIK; else { rotation = GetUninheritedRotation(bone); } angle += Mathf.DeltaAngle(angle, rotation); r = angle; float rOut = (r - pk.value) / (currentTime - pk.time); pk.outTangent = rOut; keys.Add(new Keyframe(currentTime, r, rOut, 0)); keys[pIndex] = pk; listIndex++; lastTime = currentTime; } curve = EnsureCurveKeyCount(new AnimationCurve(keys.ToArray())); string path = GetPath(bone.Data); string propertyName = "localEulerAnglesBaked"; EditorCurveBinding xBind = EditorCurveBinding.FloatCurve(path, typeof(Transform), propertyName + ".x"); AnimationUtility.SetEditorCurve(clip, xBind, new AnimationCurve()); EditorCurveBinding yBind = EditorCurveBinding.FloatCurve(path, typeof(Transform), propertyName + ".y"); AnimationUtility.SetEditorCurve(clip, yBind, new AnimationCurve()); EditorCurveBinding zBind = EditorCurveBinding.FloatCurve(path, typeof(Transform), propertyName + ".z"); AnimationUtility.SetEditorCurve(clip, zBind, curve); }