diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs index 5159bb882..b34219f67 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs @@ -27,7 +27,13 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2021_1_OR_NEWER +#define HAS_LIST_POOL +#endif + +using System.Collections.Generic; using UnityEngine; +using UnityEngine.Pool; using UnityEngine.UI; namespace Spine.Unity { @@ -53,5 +59,22 @@ namespace Spine.Unity { base.OnEnable(); this.canvasRenderer.cull = false; } + +#if HAS_LIST_POOL + public Material UpdateModifiedMaterial (Material baseMaterial) { + List modifierComponents = ListPool.Get(); + GetComponents(modifierComponents); + + Material currentMaterial = baseMaterial; + for (var i = 0; i < modifierComponents.Count; i++) + currentMaterial = modifierComponents[i].GetModifiedMaterial(currentMaterial); + ListPool.Release(modifierComponents); + return currentMaterial; + } +#else + public Material UpdateModifiedMaterial (Material baseMaterial) { + return GetModifiedMaterial(baseMaterial); + } +#endif } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs index 43c8b45e4..bbc07a4bc 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs @@ -1193,7 +1193,7 @@ namespace Spine.Unity { if (!UsesSingleSubmesh) { for (int i = 0, count = sharedMaterials.Length; i < count; ++i) { - sharedMaterials[i] = submeshGraphics[i].GetModifiedMaterial(sharedMaterials[i]); + sharedMaterials[i] = submeshGraphics[i].UpdateModifiedMaterial(sharedMaterials[i]); } } } diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json index 476b67143..a5977fcaa 100644 --- a/spine-unity/Assets/Spine/package.json +++ b/spine-unity/Assets/Spine/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-unity", "displayName": "spine-unity Runtime", "description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.", - "version": "4.3.32", + "version": "4.3.33", "unity": "2018.3", "author": { "name": "Esoteric Software",