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
a554d4f1b0
commit
51a9e34f23
@ -27,7 +27,15 @@
|
||||
* 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;
|
||||
#if HAS_LIST_POOL
|
||||
using UnityEngine.Pool;
|
||||
#endif
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Spine.Unity {
|
||||
@ -53,5 +61,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 (int 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
|
||||
}
|
||||
}
|
||||
|
||||
@ -1024,7 +1024,7 @@ namespace Spine.Unity {
|
||||
usedMaterial = multiplyMaterial;
|
||||
else if (blendMode == BlendMode.Screen && screenMaterial)
|
||||
usedMaterial = screenMaterial;
|
||||
usedMaterialItems[i] = submeshGraphics[i].GetModifiedMaterial(usedMaterial);
|
||||
usedMaterialItems[i] = submeshGraphics[i].UpdateModifiedMaterial(usedMaterial);
|
||||
}
|
||||
} else {
|
||||
Texture originalTexture = submeshMaterial.mainTexture;
|
||||
@ -1035,7 +1035,7 @@ namespace Spine.Unity {
|
||||
if (!customTextureOverride.TryGetValue(originalTexture, out usedTexture))
|
||||
usedTexture = originalTexture;
|
||||
|
||||
usedMaterialItems[i] = submeshGraphics[i].GetModifiedMaterial(usedMaterial);
|
||||
usedMaterialItems[i] = submeshGraphics[i].UpdateModifiedMaterial(usedMaterial);
|
||||
usedTextureItems[i] = usedTexture;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "com.esotericsoftware.spine.spine-unity",
|
||||
"displayName": "spine-unity Runtime",
|
||||
"description": "This plugin provides the spine-unity runtime core.",
|
||||
"version": "4.2.110",
|
||||
"version": "4.2.111",
|
||||
"unity": "2018.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user