瀏覽代碼

[unity] Fixed SkeletonGraphic MatchRectTransformWithBounds wrong scale with layoutScaleMode. Closes #2577.

Harald Csaszar 1 年之前
父節點
當前提交
b1fe837e8a

+ 5 - 3
spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs

@@ -93,6 +93,7 @@ namespace Spine.Unity {
 		/// <summary>Offset relative to the pivot position, before potential layout scale is applied.</summary>
 		[SerializeField] protected Vector2 pivotOffset = Vector2.zero;
 		[SerializeField] protected float referenceScale = 1f;
+		[SerializeField] protected float layoutScale = 1f;
 #if UNITY_EDITOR
 		protected LayoutMode previousLayoutScaleMode = LayoutMode.None;
 		[SerializeField] protected Vector2 rectTransformSize = Vector2.zero;
@@ -742,8 +743,9 @@ namespace Spine.Unity {
 				SetRectTransformSize(submeshGraphic, size);
 				submeshGraphic.rectTransform.pivot = p;
 			}
-
 			this.referenceSize = size;
+			referenceScale = referenceScale * layoutScale;
+			layoutScale = 1f;
 		}
 
 		public static void SetRectTransformSize (Graphic target, Vector2 size) {
@@ -943,7 +945,7 @@ namespace Spine.Unity {
 			meshScale = (canvas == null) ? 100 : canvas.referencePixelsPerUnit;
 			if (layoutScaleMode != LayoutMode.None) {
 				meshScale *= referenceScale;
-				float layoutScale = GetLayoutScale(layoutScaleMode);
+				layoutScale = GetLayoutScale(layoutScaleMode);
 				if (!EditReferenceRect) {
 					meshScale *= layoutScale;
 				}
@@ -1043,7 +1045,7 @@ namespace Spine.Unity {
 			meshScale = (canvas == null) ? 100 : canvas.referencePixelsPerUnit;
 			if (layoutScaleMode != LayoutMode.None) {
 				meshScale *= referenceScale;
-				float layoutScale = GetLayoutScale(layoutScaleMode);
+				layoutScale = GetLayoutScale(layoutScaleMode);
 				if (!EditReferenceRect) {
 					meshScale *= layoutScale;
 				}

+ 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.2.78",
+	"version": "4.2.79",
 	"unity": "2018.3",
 	"author": {
 		"name": "Esoteric Software",