public void Stretch(float newAnimationLength) { var keyframeOps = new KeyframesOperations(_clip); var originalAnimationLength = _clip.animationLength; _clip.animationLength = newAnimationLength; var ratio = newAnimationLength / originalAnimationLength; foreach (var target in _clip.GetAllTargets()) { var snapshots = target .GetAllKeyframesTime() .Select(t => new SnapshotAt { time = t, snapshot = target.GetSnapshot(t) }) .ToList(); keyframeOps.RemoveAll(target, true); foreach (var s in snapshots) { target.SetSnapshot((s.time * ratio).Snap(), s.snapshot); } } }
public void SelectAnimation(AtomAnimationClip clip) { if (current == clip) { return; } var previous = current; var previousSelected = selectedTargets; current = clip; selectedTargets.Clear(); foreach (var target in previousSelected) { var t = current.GetAllTargets().FirstOrDefault(x => x.TargetsSameAs(target)); if (t == null) { continue; } selectedTargets.Add(t); } onTargetsSelectionChanged.Invoke(); onCurrentAnimationChanged.Invoke(new CurrentAnimationChangedEventArgs { before = previous, after = current }); if (animation.isPlaying) { animation.PlayClip(current, animation.sequencing); } else if (!SuperController.singleton.freezeAnimation) { Sample(); } }