From 3d8b9c541d68e5729cf15d0f5b039958d27e1f46 Mon Sep 17 00:00:00 2001 From: EliyaFishman <45822259+EliyaFishman@users.noreply.github.com> Date: Wed, 7 Dec 2022 10:36:44 +0200 Subject: [PATCH] add step rotation and step scale to animations --- .../AssetGenerators/AnimationCreator.cs | 17 +++++++++++++++++ Assets/Editor/bread2unity/README.md | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Assets/Editor/bread2unity/AssetGenerators/AnimationCreator.cs b/Assets/Editor/bread2unity/AssetGenerators/AnimationCreator.cs index d0df39ec8..a27b1c709 100644 --- a/Assets/Editor/bread2unity/AssetGenerators/AnimationCreator.cs +++ b/Assets/Editor/bread2unity/AssetGenerators/AnimationCreator.cs @@ -84,6 +84,10 @@ namespace Bread2Unity var partsOfGameObject = spritesAssociatedWithPrefab.SelectMany(sprite => sprite.parts) .Where(part => bccadPrefab.RegionToChild[part.RegionIndex] == child).ToList(); + var stepScaleX = new BccadCurve(); + var stepScaleY = new BccadCurve(); + var stepRotation = new BccadCurve(); + var enabledCurve = new BccadCurve(); var xTransformCurve = new BccadCurve(); @@ -109,6 +113,10 @@ namespace Bread2Unity foreach (var currentStep in animation.Steps) { + stepRotation.AddKey(currentTime, currentStep.Rotation); + stepScaleX.AddKey(currentTime, currentStep.StretchX); + stepScaleY.AddKey(currentTime, currentStep.StretchY); + var bccadSprite = currentStep.BccadSprite; // Find the index of part of the game object var partIndex = bccadSprite.parts.Select((value, index) => new { value, index }) @@ -164,6 +172,15 @@ namespace Bread2Unity currentTime += currentStep.Delay / 30f; } + if (animation.Steps.Select(step => step.StretchX).Distinct().Count() > 1) + animationClip.SetCurve("", typeof(Transform), "localScale.x", stepScaleX); + + if (animation.Steps.Select(step => step.StretchY).Distinct().Count() > 1) + animationClip.SetCurve("", typeof(Transform), "localScale.y", stepScaleY); + + if (animation.Steps.Select(step => step.Rotation).Distinct().Count() > 1) + animationClip.SetCurve("", typeof(Transform), "localEulerAngles.z", stepRotation); + if (childIndex == 0) { enabledCurve.CopyLastKey(currentTime); diff --git a/Assets/Editor/bread2unity/README.md b/Assets/Editor/bread2unity/README.md index 5380b7b51..9a78586cc 100644 --- a/Assets/Editor/bread2unity/README.md +++ b/Assets/Editor/bread2unity/README.md @@ -13,8 +13,8 @@ Rhythm Heaven animation to Unity animation converter - [x] refactor files - [X] add color animations -- [ ] add rotation from steps -- [ ] add scale from steps +- [X] add rotation from steps +- [X] add scale from steps - [x] add translation from steps - [ ] remove bccad test