[unity] Fixed SkeletonGraphic with Multiple Canvas Renderers ignoring Mask when CustomMaterialOverride or blend modes are active. Closes #1948.

This commit is contained in:
Harald Csaszar 2021-08-31 17:52:20 +02:00
parent d6df0725a2
commit 6cd3e54b83
2 changed files with 7 additions and 3 deletions

View File

@ -244,8 +244,8 @@ namespace Spine.Unity.Editor {
} else if (meshRendersIncorrectlyWithSingleRenderer) { } else if (meshRendersIncorrectlyWithSingleRenderer) {
using (new SpineInspectorUtility.BoxScope()) { using (new SpineInspectorUtility.BoxScope()) {
meshGeneratorSettings.isExpanded = true; meshGeneratorSettings.isExpanded = true;
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("This mesh uses multiple atlas pages. You\n" + EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("This mesh uses multiple atlas pages or blend modes.\n" +
"need to enable 'Multiple Canvas Renderers'\n" + "You need to enable 'Multiple Canvas Renderers'\n" +
"for correct rendering. Consider packing\n" + "for correct rendering. Consider packing\n" +
"attachments to a single atlas page if possible.", Icons.warning), GUILayout.Height(60), GUILayout.Width(340)); "attachments to a single atlas page if possible.", Icons.warning), GUILayout.Height(60), GUILayout.Width(340));
} }

View File

@ -678,7 +678,7 @@ namespace Spine.Unity {
meshGenerator.Begin(); meshGenerator.Begin();
meshGenerator.AddSubmesh(submeshInstructionItem); meshGenerator.AddSubmesh(submeshInstructionItem);
var targetMesh = meshesItems[i]; Mesh targetMesh = meshesItems[i];
meshGenerator.ScaleVertexData(scale); meshGenerator.ScaleVertexData(scale);
if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator.Buffers); if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator.Buffers);
meshGenerator.FillVertexData(targetMesh); meshGenerator.FillVertexData(targetMesh);
@ -703,6 +703,7 @@ namespace Spine.Unity {
parent = separatorParts[++separatorSlotGroupIndex]; parent = separatorParts[++separatorSlotGroupIndex];
} }
SkeletonSubmeshGraphic submeshGraphic = submeshGraphics[i];
if (useOriginalTextureAndMaterial) { if (useOriginalTextureAndMaterial) {
Texture usedTexture = submeshMaterial.mainTexture; Texture usedTexture = submeshMaterial.mainTexture;
if (!hasBlendModeMaterials) if (!hasBlendModeMaterials)
@ -724,6 +725,7 @@ namespace Spine.Unity {
else if (blendMode == BlendMode.Screen && screenMaterial) else if (blendMode == BlendMode.Screen && screenMaterial)
usedMaterial = screenMaterial; usedMaterial = screenMaterial;
usedMaterial = submeshGraphic.GetModifiedMaterial(usedMaterial);
canvasRenderer.SetMaterial(usedMaterial, usedTexture); canvasRenderer.SetMaterial(usedMaterial, usedTexture);
#if HAS_CULL_TRANSPARENT_MESH #if HAS_CULL_TRANSPARENT_MESH
canvasRenderer.cullTransparentMesh = allowCullTransparentMesh ? canvasRenderer.cullTransparentMesh = allowCullTransparentMesh ?
@ -738,6 +740,8 @@ namespace Spine.Unity {
usedMaterial = material; usedMaterial = material;
if (!customTextureOverride.TryGetValue(originalTexture, out usedTexture)) if (!customTextureOverride.TryGetValue(originalTexture, out usedTexture))
usedTexture = originalTexture; usedTexture = originalTexture;
usedMaterial = submeshGraphic.GetModifiedMaterial(usedMaterial);
canvasRenderer.SetMaterial(usedMaterial, usedTexture); canvasRenderer.SetMaterial(usedMaterial, usedTexture);
} }
} }