diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs index fc02061e2..dde7a7a5e 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs @@ -313,7 +313,7 @@ namespace Spine.Unity { var mesh = smartMesh.mesh; meshGenerator.FillVertexData(mesh); - if (updateTriangles) meshGenerator.FillTrianglesSingle(mesh); + if (updateTriangles) meshGenerator.FillTriangles(mesh); meshGenerator.FillLateVertexData(mesh); canvasRenderer.SetMesh(mesh); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs index c37b535e3..db2461c96 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs @@ -148,7 +148,6 @@ namespace Spine.Unity { // Clear last state of attachments and submeshes instructionOutput.Clear(); // submeshInstructions.Clear(); attachments.Clear(); var workingSubmeshInstructions = instructionOutput.submeshInstructions; - workingSubmeshInstructions.Resize(1); #if SPINE_TRIANGLECHECK instructionOutput.attachments.Resize(drawOrderCount); @@ -206,11 +205,12 @@ namespace Spine.Unity { current.rawVertexCount += attachmentVertexCount; totalRawVertexCount += attachmentVertexCount; } + #if !SPINE_TK2D - if (material == null) + if (material == null && rendererObject != null) current.material = (Material)((AtlasRegion)rendererObject).page.rendererObject; #else - if (material == null) + if (material == null && rendererObject != null) current.material = (rendererObject is Material) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject; #endif @@ -218,7 +218,13 @@ namespace Spine.Unity { instructionOutput.rawVertexCount = totalRawVertexCount; #endif - workingSubmeshInstructions.Items[0] = current; + if (totalRawVertexCount > 0) { + workingSubmeshInstructions.Resize(1); + workingSubmeshInstructions.Items[0] = current; + } + else { + workingSubmeshInstructions.Resize(0); + } } public static void GenerateSkeletonRendererInstruction (SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Dictionary customSlotMaterials, List separatorSlots, bool generateMeshOverride, bool immutableTriangles = false) { @@ -1045,10 +1051,6 @@ namespace Spine.Unity { for (int i = 0; i < submeshCount; i++) mesh.SetTriangles(submeshesItems[i].Items, i, false); } - - public void FillTrianglesSingle (Mesh mesh) { - mesh.SetTriangles(submeshes.Items[0].Items, 0, false); - } #endregion public void EnsureVertexCapacity (int minimumVertexCount, bool inlcudeTintBlack = false, bool includeTangents = false, bool includeNormals = false) {