Skip to content

Commit

Permalink
Fix creating animations from an unnumbered animation while numbered a…
Browse files Browse the repository at this point in the history
…nimations exist
  • Loading branch information
acidbubbles committed Jan 7, 2021
1 parent e35d0e1 commit bd71605
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/AtomAnimations/AtomAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bd71605

Please sign in to comment.