Browse Source

[unity] SkeletonGraphic: re-joined Rebuild and MeshUpdate to fix IndexOutOfRangeException. Closes #2487.

Harald Csaszar 1 year ago
parent
commit
c36f847319

+ 2 - 8
spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs

@@ -121,7 +121,6 @@ namespace Spine.Unity {
 		public bool updateSeparatorPartScale = false;
 
 		private bool wasUpdatedAfterInit = true;
-		private bool requiresInstructionUpate = true;
 		private Texture baseTexture = null;
 
 #if UNITY_EDITOR
@@ -315,7 +314,7 @@ namespace Spine.Unity {
 			if (!this.IsValid) return;
 			if (canvasRenderer.cull) return;
 			if (update == CanvasUpdate.PreRender) {
-				if (requiresInstructionUpate) PrepareInstructionsAndRenderers(isInRebuild: true);
+				PrepareInstructionsAndRenderers(isInRebuild: true);
 				UpdateMeshToInstructions();
 			}
 			if (allowMultipleCanvasRenderers) canvasRenderer.Clear();
@@ -420,9 +419,7 @@ namespace Spine.Unity {
 			if (updateTiming == UpdateTiming.InLateUpdate)
 				Update(unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
 
-			PrepareInstructionsAndRenderers();
-
-			SetVerticesDirty(); // triggers Rebuild and avoids potential double-update in a single frame
+			UpdateMesh();
 		}
 
 		protected void OnCullStateChanged (bool culled) {
@@ -468,11 +465,9 @@ namespace Spine.Unity {
 		public Skeleton Skeleton {
 			get {
 				Initialize(false);
-				requiresInstructionUpate = true;
 				return skeleton;
 			}
 			set {
-				requiresInstructionUpate = true;
 				skeleton = value;
 			}
 		}
@@ -722,7 +717,6 @@ namespace Spine.Unity {
 		}
 
 		public void PrepareInstructionsAndRenderers (bool isInRebuild = false) {
-			requiresInstructionUpate = false;
 			if (!this.allowMultipleCanvasRenderers) {
 				MeshGenerator.GenerateSingleSubmeshInstruction(currentInstructions, skeleton, null);
 				if (canvasRenderers.Count > 0)

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