From 8d74ef06ac4b3ca7aa211e1d019ef33b34053d3d Mon Sep 17 00:00:00 2001 From: pharan Date: Thu, 18 Oct 2018 21:36:22 +0800 Subject: [PATCH] [unity] Prospective resizing for MeshGenerator AddSubmesh branch. --- .../Runtime/spine-unity/Mesh Generation/SpineMesh.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SpineMesh.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SpineMesh.cs index e779113fc..dbe8b6148 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SpineMesh.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Mesh Generation/SpineMesh.cs @@ -570,10 +570,13 @@ namespace Spine.Unity { // Add data to vertex buffers { int newVertexCount = ovc + attachmentVertexCount; - if (newVertexCount > vertexBuffer.Items.Length) { // Manual ExposedList.Resize() - Array.Resize(ref vertexBuffer.Items, newVertexCount); - Array.Resize(ref uvBuffer.Items, newVertexCount); - Array.Resize(ref colorBuffer.Items, newVertexCount); + int oldArraySize = vertexBuffer.Items.Length; + if (newVertexCount > oldArraySize) { + int newArraySize = (int)(oldArraySize * 1.3f); + if (newArraySize < newVertexCount) newArraySize = newVertexCount; + Array.Resize(ref vertexBuffer.Items, newArraySize); + Array.Resize(ref uvBuffer.Items, newArraySize); + Array.Resize(ref colorBuffer.Items, newArraySize); } vertexBuffer.Count = uvBuffer.Count = colorBuffer.Count = newVertexCount; }