mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Don't need to set submesh triangles every frame.
This commit is contained in:
parent
c4feeeb310
commit
0a7c47f2c4
@ -73,10 +73,9 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
|
|||||||
|
|
||||||
if (attachment is RegionAttachment) {
|
if (attachment is RegionAttachment) {
|
||||||
RegionAttachment regionAttachment = attachment as RegionAttachment;
|
RegionAttachment regionAttachment = attachment as RegionAttachment;
|
||||||
|
|
||||||
regionAttachment.ComputeVertices(skeleton.X, skeleton.Y, slot.Bone, vertexPositions);
|
regionAttachment.ComputeVertices(skeleton.X, skeleton.Y, slot.Bone, vertexPositions);
|
||||||
int vertexIndex = quadIndex * 4;
|
|
||||||
|
|
||||||
|
int vertexIndex = quadIndex * 4;
|
||||||
vertices[vertexIndex + 0] = new Vector3(vertexPositions[RegionAttachment.X1],vertexPositions[RegionAttachment.Y1],0);
|
vertices[vertexIndex + 0] = new Vector3(vertexPositions[RegionAttachment.X1],vertexPositions[RegionAttachment.Y1],0);
|
||||||
vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4],vertexPositions[RegionAttachment.Y4],0);
|
vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4],vertexPositions[RegionAttachment.Y4],0);
|
||||||
vertices[vertexIndex + 2] = new Vector3(vertexPositions[RegionAttachment.X2],vertexPositions[RegionAttachment.Y2],0);
|
vertices[vertexIndex + 2] = new Vector3(vertexPositions[RegionAttachment.X2],vertexPositions[RegionAttachment.Y2],0);
|
||||||
@ -106,11 +105,6 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
|
|||||||
mesh.colors32 = colors;
|
mesh.colors32 = colors;
|
||||||
mesh.uv = uvs;
|
mesh.uv = uvs;
|
||||||
|
|
||||||
mesh.subMeshCount = submeshIndices.Count;
|
|
||||||
for(int i = 0; i < mesh.subMeshCount; ++i) {
|
|
||||||
mesh.SetTriangles(submeshIndices[i],i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skeletonDataAsset.normalGenerationMode != tk2dSpriteCollection.NormalGenerationMode.None) {
|
if (skeletonDataAsset.normalGenerationMode != tk2dSpriteCollection.NormalGenerationMode.None) {
|
||||||
mesh.RecalculateNormals();
|
mesh.RecalculateNormals();
|
||||||
|
|
||||||
@ -142,13 +136,22 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
|
|||||||
#endif
|
#endif
|
||||||
if (quadCount == cachedQuadCount) return;
|
if (quadCount == cachedQuadCount) return;
|
||||||
|
|
||||||
mesh.Clear();
|
|
||||||
cachedQuadCount = quadCount;
|
cachedQuadCount = quadCount;
|
||||||
vertices = new Vector3[quadCount * 4];
|
vertices = new Vector3[quadCount * 4];
|
||||||
uvs = new Vector2[quadCount * 4];
|
uvs = new Vector2[quadCount * 4];
|
||||||
colors = new Color32[quadCount * 4];
|
colors = new Color32[quadCount * 4];
|
||||||
|
|
||||||
UpdateSubmeshCache();
|
UpdateSubmeshCache();
|
||||||
|
|
||||||
|
mesh.Clear();
|
||||||
|
mesh.vertices = vertices;
|
||||||
|
mesh.colors32 = colors;
|
||||||
|
mesh.uv = uvs;
|
||||||
|
|
||||||
|
mesh.subMeshCount = submeshIndices.Count;
|
||||||
|
for(int i = 0; i < mesh.subMeshCount; ++i) {
|
||||||
|
mesh.SetTriangles(submeshIndices[i],i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSubmeshCache() {
|
private void UpdateSubmeshCache() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user