mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 01:06:00 +08:00
[unity] Fix SkeletonSubmeshGraphic issue with multiple IMaterialModifier components. Closes #2966.
This commit is contained in:
parent
27f5750445
commit
6f54ee042d
@ -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<IMaterialModifier> modifierComponents = ListPool<IMaterialModifier>.Get();
|
||||
GetComponents<IMaterialModifier>(modifierComponents);
|
||||
|
||||
Material currentMaterial = baseMaterial;
|
||||
for (var i = 0; i < modifierComponents.Count; i++)
|
||||
currentMaterial = modifierComponents[i].GetModifiedMaterial(currentMaterial);
|
||||
ListPool<IMaterialModifier>.Release(modifierComponents);
|
||||
return currentMaterial;
|
||||
}
|
||||
#else
|
||||
public Material UpdateModifiedMaterial (Material baseMaterial) {
|
||||
return GetModifiedMaterial(baseMaterial);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user