From 9487d3a5f37656a3123b5ec4a76db1306dbaf5cb Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 21 Sep 2023 19:28:57 +0200 Subject: [PATCH] [unity] BoneFollowerGraphic does not respect LayoutScaleMode. Closes #2378. --- .../Editor/Components/BoneFollowerGraphicInspector.cs | 3 +-- .../Components/Following/BoneFollowerGraphic.cs | 4 +--- .../Components/Following/BoundingBoxFollowerGraphic.cs | 5 +---- .../Components/RootMotion/SkeletonRootMotion.cs | 8 +++----- .../Components/RootMotion/SkeletonRootMotionBase.cs | 1 - .../Components/SkeletonUtility/SkeletonUtility.cs | 10 ++-------- spine-unity/Assets/Spine/package.json | 2 +- 7 files changed, 9 insertions(+), 24 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerGraphicInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerGraphicInspector.cs index 29539cc4f..a729ae900 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerGraphicInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/BoneFollowerGraphicInspector.cs @@ -99,8 +99,7 @@ namespace Spine.Unity.Editor { Transform transform = skeletonGraphicComponent.transform; Skeleton skeleton = skeletonGraphicComponent.Skeleton; - Canvas canvas = skeletonGraphicComponent.canvas; - float positionScale = canvas == null ? 1f : skeletonGraphicComponent.canvas.referencePixelsPerUnit; + float positionScale = skeletonGraphicComponent.MeshScale; if (string.IsNullOrEmpty(boneName.stringValue)) { SpineHandles.DrawBones(transform, skeleton, positionScale); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs index 3f0e0945e..8735e0fc1 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoneFollowerGraphic.cs @@ -139,9 +139,7 @@ namespace Spine.Unity { RectTransform thisTransform = this.transform as RectTransform; if (thisTransform == null) return; - Canvas canvas = skeletonGraphic.canvas; - if (canvas == null) canvas = skeletonGraphic.GetComponentInParent(); - float scale = canvas != null ? canvas.referencePixelsPerUnit : 100.0f; + float scale = skeletonGraphic.MeshScale; float additionalFlipScale = 1; if (skeletonTransformIsParent) { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs index af66d87fc..dcc46b3ea 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs @@ -125,10 +125,7 @@ namespace Spine.Unity { int requiredCollidersCount = 0; PolygonCollider2D[] colliders = GetComponents(); if (this.gameObject.activeInHierarchy) { - Canvas canvas = skeletonGraphic.canvas; - if (canvas == null) canvas = skeletonGraphic.GetComponentInParent(); - float scale = canvas != null ? canvas.referencePixelsPerUnit : 100.0f; - + float scale = skeletonGraphic.MeshScale; foreach (Skin skin in skeleton.Data.Skins) AddCollidersForSkin(skin, slotIndex, colliders, scale, ref requiredCollidersCount); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotion.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotion.cs index 3d05f2dbb..6bc6c0b60 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotion.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotion.cs @@ -54,7 +54,7 @@ namespace Spine.Unity { #endregion AnimationState animationState; - Canvas canvas; + SkeletonGraphic skeletonGraphic; public override Vector2 GetRemainingRootMotion (int trackIndex) { TrackEntry track = animationState.GetCurrent(trackIndex); @@ -79,7 +79,7 @@ namespace Spine.Unity { protected override float AdditionalScale { get { - return canvas ? canvas.referencePixelsPerUnit : 1.0f; + return skeletonGraphic ? skeletonGraphic.MeshScale : 1.0f; } } @@ -93,9 +93,7 @@ namespace Spine.Unity { IAnimationStateComponent animstateComponent = skeletonComponent as IAnimationStateComponent; this.animationState = (animstateComponent != null) ? animstateComponent.AnimationState : null; - if (this.GetComponent() != null) { - canvas = this.GetComponentInParent(); - } + skeletonGraphic = this.GetComponent(); } protected override Vector2 CalculateAnimationsMovementDelta () { 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 e19b8b1d2..f9a00ecfc 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 @@ -483,7 +483,6 @@ namespace Spine.Unity { int GetConstraintLastPosIndex (int constraintIndex) { ExposedList constraints = skeletonComponent.Skeleton.TransformConstraints; - TransformConstraint targetConstraint = constraints.Items[constraintIndex]; return transformConstraintIndices.FindIndex(addedIndex => addedIndex == constraintIndex); } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs index ceb7f3811..20471e0a0 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs @@ -157,14 +157,13 @@ namespace Spine.Unity { } } - if (canvas != null) { - positionScale = canvas.referencePixelsPerUnit; + if (skeletonGraphic != null) { + positionScale = skeletonGraphic.MeshScale; } } [HideInInspector] public SkeletonRenderer skeletonRenderer; [HideInInspector] public SkeletonGraphic skeletonGraphic; - private Canvas canvas; [System.NonSerialized] public ISkeletonAnimation skeletonAnimation; private ISkeletonComponent skeletonComponent; @@ -233,11 +232,6 @@ namespace Spine.Unity { } else if (skeletonGraphic != null) { skeletonGraphic.OnRebuild -= HandleRendererReset; skeletonGraphic.OnRebuild += HandleRendererReset; - canvas = skeletonGraphic.canvas; - if (canvas == null) - canvas = skeletonGraphic.GetComponentInParent(); - if (canvas == null) - positionScale = 100.0f; } if (skeletonAnimation != null) { diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json index a2abb5faf..ac358f72b 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.1.24", + "version": "4.1.25", "unity": "2018.3", "author": { "name": "Esoteric Software",