public override void StartTimeline() { sourcePosition = AffectedObject.transform.localPosition; sourceOrientation = AffectedObject.transform.localRotation; sourceSpeed = Animator.speed; for (var layer = 0; layer < Animator.layerCount; layer++) { initialAnimationInfo[layer] = new List <AnimatorClipInfo>(); var values = Animator.GetCurrentAnimatorClipInfo(layer); foreach (var value in values) { initialAnimationInfo[layer].Add(value); } } for (var layer = 0; layer < Animator.layerCount; layer++) { initialAnimatorStateInfo[layer] = Animator.GetCurrentAnimatorStateInfo(layer); } if (Animator.applyRootMotion) { var existingComponents = Animator.gameObject.GetComponents <AnimationTimelineController>(); foreach (var existingComponent in existingComponents) { DestroyImmediate(existingComponent); } animationTimelineController = Animator.gameObject.AddComponent <AnimationTimelineController>(); animationTimelineController.AnimationTimeline = this; } previousEnabled = Animator.enabled; Animator.enabled = false; }
public override void StopTimeline() { if (this.animationTimelineController) { UnityEngine.Object.DestroyImmediate(this.animationTimelineController); } this.animationTimelineController = null; this.Animator.Update(-base.Sequence.RunningTime); this.Animator.StopPlayback(); this.ResetAnimation(); this.initialAnimationInfo.Clear(); this.initialAnimatorStateInfo.Clear(); this.GameRunner.Stop(); this.EditorRunner.Stop(); this.Animator.speed = this.sourceSpeed; }
public override void StartTimeline() { this.sourcePosition = base.AffectedObject.transform.localPosition; this.sourceOrientation = base.AffectedObject.transform.localRotation; this.sourceSpeed = this.Animator.speed; for (int i = 0; i < this.Animator.layerCount; i++) { this.initialAnimationInfo[i] = new List <AnimationInfo>(this.Animator.GetCurrentAnimationClipState(i).ToList <AnimationInfo>()); } for (int j = 0; j < this.Animator.layerCount; j++) { this.initialAnimatorStateInfo[j] = this.Animator.GetCurrentAnimatorStateInfo(j); } if (this.Animator.applyRootMotion) { this.animationTimelineController = this.Animator.gameObject.AddComponent <AnimationTimelineController>(); this.animationTimelineController.AnimationTimeline = this; } }
public override void StopTimeline() { if (animationTimelineController) { DestroyImmediate(animationTimelineController); } animationTimelineController = null; Animator.Update(-Sequence.RunningTime); Animator.StopPlayback(); ResetAnimation(); initialAnimationInfo.Clear(); initialAnimatorStateInfo.Clear(); GameRunner.Stop(); EditorRunner.Stop(); Animator.speed = sourceSpeed; Animator.enabled = previousEnabled; }