[unity] Fix case where only materials changed.

This commit is contained in:
John 2016-12-15 05:52:51 +08:00 committed by GitHub
parent 7dbf7c5268
commit d2eebdf81f

View File

@ -534,11 +534,20 @@ namespace Spine.Unity {
bool mustUpdateRendererMaterials = mustUpdateMeshStructure ||
(lastPushedMaterials.Length != submeshCount);
// Assumption at this point: (lastPushedMaterials.Count == workingSubmeshInstructions.Count == thisSubmeshMaterials.Count == submeshCount)
// Case: mesh structure or submesh count did not change but materials changed.
if (!mustUpdateRendererMaterials) {
var workingSubmeshInstructionsItems = workingSubmeshInstructions.Items;
for (int i = 0, n = lastPushedMaterials.Length; i < n; i++) {
if (lastPushedMaterials[i].GetInstanceID() != workingSubmeshInstructionsItems[i].material.GetInstanceID()) { // Bounds check is implied above.
for (int i = 0; i < submeshCount; i++) {
if (lastPushedMaterials[i].GetInstanceID() != workingSubmeshInstructionsItems[i].material.GetInstanceID()) { // Bounds check is implied by submeshCount above.
mustUpdateRendererMaterials = true;
{
var thisSubmeshMaterials = this.submeshMaterials.Items;
if (mustUpdateRendererMaterials)
for (int j = 0; j < submeshCount; j++)
thisSubmeshMaterials[j] = workingSubmeshInstructionsItems[j].material;
}
break;
}
}