From 7978a1b1ffd80746b01698b7bf9a45ba58edcc3d Mon Sep 17 00:00:00 2001 From: Acid Bubbles Date: Wed, 8 Sep 2021 01:36:19 -0400 Subject: [PATCH] When splitting, change the layer name, not the anim name and add them in order --- src/AtomAnimations/Operations/LayersOperations.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/AtomAnimations/Operations/LayersOperations.cs b/src/AtomAnimations/Operations/LayersOperations.cs index f01e3d1b..0975d5b7 100644 --- a/src/AtomAnimations/Operations/LayersOperations.cs +++ b/src/AtomAnimations/Operations/LayersOperations.cs @@ -22,11 +22,12 @@ public AtomAnimationClip Add() public void SplitLayer(List targets) { - var layerName = GetSplitAnimationName(_clip.animationLayer, _animation.index.ByLayer().Select(c => c[0].animationLayer).ToList()); - foreach (var sourceClip in _animation.index.ByLayer(_clip.animationLayer).Reverse().ToList()) + var layerName = GetSplitLayerName(_clip.animationLayer, _animation.index.ByLayer().Select(c => c[0].animationLayer).ToList()); + foreach (var sourceClip in _animation.index.ByLayer(_clip.animationLayer).ToList()) { - var newClip = _animation.CreateClip(layerName, GetSplitAnimationName(sourceClip.animationName, _animation.clips.Select(c => c.animationName).ToList())); + var newClip = _animation.CreateClip(layerName, sourceClip.animationName); sourceClip.CopySettingsTo(newClip); + newClip.animationLayer = layerName; foreach (var t in sourceClip.GetAllTargets().Where(t => targets.Any(t.TargetsSameAs)).ToList()) { sourceClip.Remove(t); @@ -56,11 +57,11 @@ private string GetNewAnimationName() return Guid.NewGuid().ToString(); } - private static string GetSplitAnimationName(string sourceAnimationName, IList list) + private static string GetSplitLayerName(string sourceLayerName, IList list) { for (var i = 1; i < 999; i++) { - var animationName = $"{sourceAnimationName} (Split {i})"; + var animationName = $"{sourceLayerName} (Split {i})"; if (list.All(n => n != animationName)) return animationName; } return Guid.NewGuid().ToString();