From 3e8c9dfa6681a8d3fab736158eda4402bc85ea80 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 16 Jul 2024 18:14:17 +0200 Subject: [PATCH] [unity] Fixed SkeletonRootMotion ignoring parent bone scale set via transform constraints. Closes #2580. --- CHANGELOG.md | 3 ++- .../Components/RootMotion/SkeletonRootMotionBase.cs | 11 +++++++++++ spine-unity/Assets/Spine/package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e71f765f2..f504cf432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -122,7 +122,7 @@ ### Unity -- **Officially supported Unity versions are 2017.1-2022.1**. +- **Officially supported Unity versions are 2017.1-2023.1**. - **Additions** @@ -174,6 +174,7 @@ - Inspector: String attribute `SpineSkin()` now allows to include `` in the list of parameters. Previously the `includeNone=true` parameter of the `SpineSkin()` attribute defaulted to `true` but was ignored. Now it defaults to `false` and has an effect on the list. Only the Inspector GUI is affected by this behaviour change. - `SkeletonGraphicRenderTexture` example component: `protected RawImage quadRawImage` was changed to `protected SkeletonSubmeshGraphic quadMaskableGraphic` for a bugfix. This is only relevant for subclasses of `SkeletonGraphicRenderTexture` or when querying the `RawImage` component via e.g. `skeletonGraphicRenderTexture.quad.GetComponent()`. - Fixed a bug where when Linear color space is used and `PMA vertex colors` enabled, additive slots add a too dark (too transparent) color value. If you want the old incorrect behaviour (darker additive slots) or are not using Linear but Gamma color space, you can comment-out the define `LINEAR_COLOR_SPACE_FIX_ADDITIVE_ALPHA` in `MeshGenerator.cs` to deactivate the fix or just to skip unnecessary instructions. + - Fixed SkeletonRootMotion components ignoring parent bone scale when set by transform constraints. Using applied scale of parent bone now. If you need the old behaviour, comment out the line `#define USE_APPLIED_PARENT_SCALE` in SkeletonRootMotionBase.cs. - **Changes of default values** diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs index 1a260768f..7559a7039 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs @@ -27,6 +27,12 @@ * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +// In order to respect TransformConstraints modifying the scale of parent bones, +// GetScaleAffectingRootMotion() now uses parentBone.AScaleX and AScaleY instead +// of previously used ScaleX and ScaleY. If you require the previous behaviour, +// comment out the define below. +#define USE_APPLIED_PARENT_SCALE + using Spine.Unity.AnimationTools; using System; using System.Collections.Generic; @@ -641,8 +647,13 @@ namespace Spine.Unity { parentBoneScale = Vector2.one; Bone scaleBone = rootMotionBone; while ((scaleBone = scaleBone.Parent) != null) { +#if USE_APPLIED_PARENT_SCALE + parentBoneScale.x *= scaleBone.AScaleX; + parentBoneScale.y *= scaleBone.AScaleY; +#else parentBoneScale.x *= scaleBone.ScaleX; parentBoneScale.y *= scaleBone.ScaleY; +#endif } totalScale = Vector2.Scale(totalScale, parentBoneScale); totalScale *= AdditionalScale; diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json index 5150344c7..4e722c65b 100644 --- a/spine-unity/Assets/Spine/package.json +++ b/spine-unity/Assets/Spine/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-unity", "displayName": "spine-unity Runtime", "description": "This plugin provides the spine-unity runtime core.", - "version": "4.2.77", + "version": "4.2.78", "unity": "2018.3", "author": { "name": "Esoteric Software",