Hello!
I noticed that when trying to change multiple components at runtime, or swapping skins, the entire mesh would disappear (latest runtimes/unity). This is apparent with the most recent goblin demo.
Our programmer had a look and seems to have fixed the bug found in SkeletonAnimation.cs. Starting at line 236. Hopefully you find this helpful.
Cheers,
J
if (newTriangles && calculateNormals) {
Vector3[] normals = new Vector3[vertexCount];
Vector3 normal = new Vector3(0, 0, -1);
for (int i = 0; i < vertexCount; i++)
{
normals[i] = normal;
}
(useMesh1 ? mesh2 : mesh1).vertices = vertices; // Set other mesh vertices.
mesh1.normals = normals;
mesh2.normals = normals;
if (calculateTangents) {
Vector4[] tangents = new Vector4[vertexCount];
Vector3 tangent = new Vector3(0, 0, 1);
for (int i = 0; i < vertexCount; i++)
tangents[i] = tangent;
mesh1.tangents = tangents;
mesh2.tangents = tangents;
}
}
useMesh1 = !useMesh1;
}
/** Adds a material. Adds submesh indexes if existing indexes aren't sufficient. */
private void addSubmesh (Material material, int endQuadCount, int submeshQuadCount, bool lastSubmesh) {
int submeshIndex = submeshMaterials.Count;
submeshMaterials.Add(material);
int indexCount = submeshQuadCount * 6;
int vertexIndex = (endQuadCount - submeshQuadCount) * 4;
if (submeshes.Count <= submeshIndex) submeshes.Add(new Submesh());
Submesh submesh = submeshes[submeshIndex];
// Allocate indexes if not the right size, allowing last submesh to have more than required.
int[] indexes = submesh.indexes;
bool regenerated = false;
if (lastSubmesh ? (indexes.Length < indexCount) : (indexes.Length != indexCount)) {
submesh.indexes = indexes = new int[indexCount];
submesh.indexCount = 0;
regenerated = true;
}
// Last submesh may have more indices than required, so zero indexes to the end.
if (lastSubmesh && (submesh.indexCount != indexCount)) {
submesh.indexCount = indexCount;
for (int i = indexCount, n = indexes.Length; i < n; i++)
indexes[i] = 0;
}
// Set indexes if not already set.
if ((submesh.firstVertex != vertexIndex) || (submesh.indexCount < indexCount) || regenerated) {
submesh.indexCount = indexCount;
submesh.firstVertex = vertexIndex;
for (int i = 0; i < indexCount; i += 6, vertexIndex += 4) {
indexes[i] = vertexIndex;
indexes[i + 1] = vertexIndex + 2;
indexes[i + 2] = vertexIndex + 1;
indexes[i + 3] = vertexIndex + 2;
indexes[i + 4] = vertexIndex + 3;
indexes[i + 5] = vertexIndex + 1;
}