Skip to content

Commit

Permalink
When splitting, change the layer name, not the anim name and add them…
Browse files Browse the repository at this point in the history
… in order
  • Loading branch information
acidbubbles committed Sep 8, 2021
1 parent 325931f commit 7978a1b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/AtomAnimations/Operations/LayersOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ public AtomAnimationClip Add()

public void SplitLayer(List<IAtomAnimationTarget> 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);
Expand Down Expand Up @@ -56,11 +57,11 @@ private string GetNewAnimationName()
return Guid.NewGuid().ToString();
}

private static string GetSplitAnimationName(string sourceAnimationName, IList<string> list)
private static string GetSplitLayerName(string sourceLayerName, IList<string> 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();
Expand Down

0 comments on commit 7978a1b

Please sign in to comment.