one more is + as -> as + null check

This commit is contained in:
ZimM 2015-02-26 14:40:59 +02:00
parent 0b86e3330a
commit 905890f7ca

View File

@ -303,8 +303,8 @@ public class SkeletonRenderer : MonoBehaviour {
} else { } else {
if (!renderMeshes) if (!renderMeshes)
continue; continue;
if (attachment is MeshAttachment) { MeshAttachment meshAttachment = attachment as MeshAttachment;
MeshAttachment meshAttachment = (MeshAttachment)attachment; if (meshAttachment != null) {
int meshVertexCount = meshAttachment.vertices.Length; int meshVertexCount = meshAttachment.vertices.Length;
if (tempVertices.Length < meshVertexCount) if (tempVertices.Length < meshVertexCount)
this.tempVertices = tempVertices = new float[meshVertexCount]; this.tempVertices = tempVertices = new float[meshVertexCount];
@ -327,29 +327,31 @@ public class SkeletonRenderer : MonoBehaviour {
uvs[vertexIndex].x = meshUVs[ii]; uvs[vertexIndex].x = meshUVs[ii];
uvs[vertexIndex].y = meshUVs[ii + 1]; uvs[vertexIndex].y = meshUVs[ii + 1];
} }
} else if (attachment is SkinnedMeshAttachment) { } else {
SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment; SkinnedMeshAttachment skinnedMeshAttachment = attachment as SkinnedMeshAttachment;
int meshVertexCount = meshAttachment.uvs.Length; if (skinnedMeshAttachment != null) {
if (tempVertices.Length < meshVertexCount) int meshVertexCount = skinnedMeshAttachment.uvs.Length;
this.tempVertices = tempVertices = new float[meshVertexCount]; if (tempVertices.Length < meshVertexCount)
meshAttachment.ComputeWorldVertices(slot, tempVertices); this.tempVertices = tempVertices = new float[meshVertexCount];
skinnedMeshAttachment.ComputeWorldVertices(slot, tempVertices);
color.a = (byte)(a * slot.a * meshAttachment.a); color.a = (byte)(a * slot.a * skinnedMeshAttachment.a);
color.r = (byte)(r * slot.r * meshAttachment.r * color.a); color.r = (byte)(r * slot.r * skinnedMeshAttachment.r * color.a);
color.g = (byte)(g * slot.g * meshAttachment.g * color.a); color.g = (byte)(g * slot.g * skinnedMeshAttachment.g * color.a);
color.b = (byte)(b * slot.b * meshAttachment.b * color.a); color.b = (byte)(b * slot.b * skinnedMeshAttachment.b * color.a);
if (slot.data.additiveBlending) if (slot.data.additiveBlending)
color.a = 0; color.a = 0;
float[] meshUVs = meshAttachment.uvs; float[] meshUVs = skinnedMeshAttachment.uvs;
float z = i * zSpacing; float z = i * zSpacing;
for (int ii = 0; ii < meshVertexCount; ii += 2, vertexIndex++) { for (int ii = 0; ii < meshVertexCount; ii += 2, vertexIndex++) {
vertices[vertexIndex].x = tempVertices[ii]; vertices[vertexIndex].x = tempVertices[ii];
vertices[vertexIndex].y = tempVertices[ii + 1]; vertices[vertexIndex].y = tempVertices[ii + 1];
vertices[vertexIndex].z = z; vertices[vertexIndex].z = z;
colors[vertexIndex] = color; colors[vertexIndex] = color;
uvs[vertexIndex].x = meshUVs[ii]; uvs[vertexIndex].x = meshUVs[ii];
uvs[vertexIndex].y = meshUVs[ii + 1]; uvs[vertexIndex].y = meshUVs[ii + 1];
}
} }
} }
} }