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

This commit is contained in:
Harald Csaszar 2024-03-19 16:13:30 +01:00
parent bd781912da
commit c36f847319
2 changed files with 3 additions and 9 deletions

View File

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

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