From defa80c78d86f55278e6309938c4c27c4d062d6a Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 11 Sep 2023 21:12:56 +0200 Subject: [PATCH] [unity] Fixed compile error on older Unity versions of `RenderCombinedMesh`. See commit ed75bff. --- .../Sample Components/RenderCombinedMesh.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RenderCombinedMesh.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RenderCombinedMesh.cs index 8aa03bd20..d1dfddcf3 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RenderCombinedMesh.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/RenderCombinedMesh.cs @@ -31,6 +31,10 @@ #define NEW_PREFAB_SYSTEM #endif +#if UNITY_2019_3_OR_NEWER +#define SET_VERTICES_HAS_LENGTH_PARAMETER +#endif + using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -230,10 +234,26 @@ namespace Spine.Unity.Examples { } Mesh combinedMesh = doubleBufferedMesh.GetNext(); +#if SET_VERTICES_HAS_LENGTH_PARAMETER combinedMesh.SetVertices(this.positionBuffer.Items, 0, this.positionBuffer.Count); combinedMesh.SetUVs(0, this.uvBuffer.Items, 0, this.uvBuffer.Count); combinedMesh.SetColors(this.colorBuffer.Items, 0, this.colorBuffer.Count); combinedMesh.SetTriangles(this.indexBuffer.Items, 0, this.indexBuffer.Count, 0); +#else + // fill excess with zero positions + { + int listCount = this.positionBuffer.Count; + Vector3[] positionArray = this.positionBuffer.Items; + int arrayLength = positionArray.Length; + Vector3 vector3zero = Vector3.zero; + for (int i = listCount; i < arrayLength; i++) + positionArray[i] = vector3zero; + } + combinedMesh.vertices = this.positionBuffer.Items; + combinedMesh.uv = this.uvBuffer.Items; + combinedMesh.colors32 = this.colorBuffer.Items; + combinedMesh.triangles = this.indexBuffer.Items; +#endif ownMeshFilter.sharedMesh = combinedMesh; }