소스 검색

[unity] BoneFollowerGraphic does not respect LayoutScaleMode. Closes #2378.

Harald Csaszar 2 년 전
부모
커밋
9487d3a5f3

+ 1 - 2
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);

+ 1 - 3
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<Canvas>();
-			float scale = canvas != null ? canvas.referencePixelsPerUnit : 100.0f;
+			float scale = skeletonGraphic.MeshScale;
 
 			float additionalFlipScale = 1;
 			if (skeletonTransformIsParent) {

+ 1 - 4
spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs

@@ -125,10 +125,7 @@ namespace Spine.Unity {
 			int requiredCollidersCount = 0;
 			PolygonCollider2D[] colliders = GetComponents<PolygonCollider2D>();
 			if (this.gameObject.activeInHierarchy) {
-				Canvas canvas = skeletonGraphic.canvas;
-				if (canvas == null) canvas = skeletonGraphic.GetComponentInParent<Canvas>();
-				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);
 

+ 3 - 5
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<CanvasRenderer>() != null) {
-				canvas = this.GetComponentInParent<Canvas>();
-			}
+			skeletonGraphic = this.GetComponent<SkeletonGraphic>();
 		}
 
 		protected override Vector2 CalculateAnimationsMovementDelta () {

+ 0 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs

@@ -483,7 +483,6 @@ namespace Spine.Unity {
 
 		int GetConstraintLastPosIndex (int constraintIndex) {
 			ExposedList<TransformConstraint> constraints = skeletonComponent.Skeleton.TransformConstraints;
-			TransformConstraint targetConstraint = constraints.Items[constraintIndex];
 			return transformConstraintIndices.FindIndex(addedIndex => addedIndex == constraintIndex);
 		}
 

+ 2 - 8
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<Canvas>();
-				if (canvas == null)
-					positionScale = 100.0f;
 			}
 
 			if (skeletonAnimation != null) {

+ 1 - 1
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",