[unity] Fixed SkeletonRootMotion ignoring parent bone scale set via transform constraints. Closes #2580.

This commit is contained in:
Harald Csaszar 2024-07-16 18:14:17 +02:00
parent 59bcffcf42
commit 3e8c9dfa66
3 changed files with 14 additions and 2 deletions

View File

@ -122,7 +122,7 @@
### Unity ### Unity
- **Officially supported Unity versions are 2017.1-2022.1**. - **Officially supported Unity versions are 2017.1-2023.1**.
- **Additions** - **Additions**
@ -174,6 +174,7 @@
- Inspector: String attribute `SpineSkin()` now allows to include `<None>` 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. - Inspector: String attribute `SpineSkin()` now allows to include `<None>` 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<RawImage>()`. - `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<RawImage>()`.
- 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 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** - **Changes of default values**

View File

@ -27,6 +27,12 @@
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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 Spine.Unity.AnimationTools;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -641,8 +647,13 @@ namespace Spine.Unity {
parentBoneScale = Vector2.one; parentBoneScale = Vector2.one;
Bone scaleBone = rootMotionBone; Bone scaleBone = rootMotionBone;
while ((scaleBone = scaleBone.Parent) != null) { while ((scaleBone = scaleBone.Parent) != null) {
#if USE_APPLIED_PARENT_SCALE
parentBoneScale.x *= scaleBone.AScaleX;
parentBoneScale.y *= scaleBone.AScaleY;
#else
parentBoneScale.x *= scaleBone.ScaleX; parentBoneScale.x *= scaleBone.ScaleX;
parentBoneScale.y *= scaleBone.ScaleY; parentBoneScale.y *= scaleBone.ScaleY;
#endif
} }
totalScale = Vector2.Scale(totalScale, parentBoneScale); totalScale = Vector2.Scale(totalScale, parentBoneScale);
totalScale *= AdditionalScale; totalScale *= AdditionalScale;

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity", "name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime", "displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core.", "description": "This plugin provides the spine-unity runtime core.",
"version": "4.2.77", "version": "4.2.78",
"unity": "2018.3", "unity": "2018.3",
"author": { "author": {
"name": "Esoteric Software", "name": "Esoteric Software",