From bd7160565515870505eb8af78c9977737bde1f24 Mon Sep 17 00:00:00 2001 From: Acid Bubbles Date: Wed, 6 Jan 2021 22:22:37 -0500 Subject: [PATCH] Fix creating animations from an unnumbered animation while numbered animations exist --- src/AtomAnimations/AtomAnimation.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/AtomAnimations/AtomAnimation.cs b/src/AtomAnimations/AtomAnimation.cs index 418a0a02..07a8098c 100644 --- a/src/AtomAnimations/AtomAnimation.cs +++ b/src/AtomAnimations/AtomAnimation.cs @@ -158,9 +158,18 @@ public void RemoveClip(AtomAnimationClip clip) private string GetNewAnimationName(AtomAnimationClip source) { var match = _lastDigitsRegex.Match(source.animationName); - if (!match.Success) return source.animationName + " 2"; - var animationNameBeforeInt = match.Groups["name"].Value; - var animationNameInt = int.Parse(match.Groups["index"].Value); + string animationNameBeforeInt; + int animationNameInt; + if (!match.Success) + { + animationNameBeforeInt = $"{source.animationName.TrimEnd()} "; + animationNameInt = 1; + } + else + { + animationNameBeforeInt = match.Groups["name"].Value; + animationNameInt = int.Parse(match.Groups["index"].Value); + } for (var i = animationNameInt + 1; i < 999; i++) { var animationName = animationNameBeforeInt + i;