Quellcode durchsuchen

[unity] Prevent null reference exception when using `Advanced - Fix Draw Order` and disabling the renderer and/or GameObject.

Harald Csaszar vor 4 Jahren
Ursprung
Commit
1e888db53a

+ 3 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs

@@ -690,6 +690,9 @@ namespace Spine.Unity {
 			}
 
 			for (int i = 0; i < meshRenderer.sharedMaterials.Length; ++i) {
+				if (!meshRenderer.sharedMaterials[i])
+					continue;
+
 				if (!hasPerRendererBlock) meshRenderer.GetPropertyBlock(reusedPropertyBlock, i);
 				// Note: this parameter shall not exist at any shader, then Unity will create separate
 				// material instances (not in terms of memory cost or leakage).