mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-25 19:21:26 +08:00
[unity] Fix case where only materials changed.
This commit is contained in:
parent
7dbf7c5268
commit
d2eebdf81f
@ -534,11 +534,20 @@ namespace Spine.Unity {
|
|||||||
bool mustUpdateRendererMaterials = mustUpdateMeshStructure ||
|
bool mustUpdateRendererMaterials = mustUpdateMeshStructure ||
|
||||||
(lastPushedMaterials.Length != submeshCount);
|
(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) {
|
if (!mustUpdateRendererMaterials) {
|
||||||
var workingSubmeshInstructionsItems = workingSubmeshInstructions.Items;
|
var workingSubmeshInstructionsItems = workingSubmeshInstructions.Items;
|
||||||
for (int i = 0, n = lastPushedMaterials.Length; i < n; i++) {
|
for (int i = 0; i < submeshCount; i++) {
|
||||||
if (lastPushedMaterials[i].GetInstanceID() != workingSubmeshInstructionsItems[i].material.GetInstanceID()) { // Bounds check is implied above.
|
if (lastPushedMaterials[i].GetInstanceID() != workingSubmeshInstructionsItems[i].material.GetInstanceID()) { // Bounds check is implied by submeshCount above.
|
||||||
mustUpdateRendererMaterials = true;
|
mustUpdateRendererMaterials = true;
|
||||||
|
{
|
||||||
|
var thisSubmeshMaterials = this.submeshMaterials.Items;
|
||||||
|
if (mustUpdateRendererMaterials)
|
||||||
|
for (int j = 0; j < submeshCount; j++)
|
||||||
|
thisSubmeshMaterials[j] = workingSubmeshInstructionsItems[j].material;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user