Skip to content

Commit 3b095bc

Browse files
committed
fix: fix a potential ArgumentOutOfRangeException that could occur when changing the FontAsset in TextMeshPro
close #327
1 parent 2a90098 commit 3b095bc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Packages/src/Runtime/Internal/Extensions/MeshExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ public static void CopyTo(this Mesh self, VertexHelper dst, int vertexCount, int
115115
normals.GetOrDefault(i), tangents.GetOrDefault(i));
116116
}
117117

118-
for (var i = 0; i < indexCount - 2; i += 3)
118+
var count = Mathf.Clamp(indexCount, 0, indices.Count);
119+
for (var i = 0; i < count - 2; i += 3)
119120
{
120121
dst.AddTriangle(indices[i], indices[i + 1], indices[i + 2]);
121122
}

0 commit comments

Comments
 (0)