mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
[unity] Allow empty slots as separators.
This commit is contained in:
parent
8e138b56e0
commit
015ade60ea
@ -38,7 +38,6 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace Spine.Unity {
|
namespace Spine.Unity {
|
||||||
public static class SpineMesh {
|
public static class SpineMesh {
|
||||||
|
|
||||||
internal const HideFlags MeshHideflags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
|
internal const HideFlags MeshHideflags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
|
||||||
|
|
||||||
/// <summary>Factory method for creating a new mesh for use in Spine components. This can be called in field initializers.</summary>
|
/// <summary>Factory method for creating a new mesh for use in Spine components. This can be called in field initializers.</summary>
|
||||||
@ -132,6 +131,8 @@ namespace Spine.Unity {
|
|||||||
[NonSerialized] ExposedList<Vector2> uv3;
|
[NonSerialized] ExposedList<Vector2> uv3;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public int VertexCount { get { return vertexBuffer.Count; } }
|
||||||
|
|
||||||
#region Step 1 : Generate Instructions
|
#region Step 1 : Generate Instructions
|
||||||
public static void GenerateSingleSubmeshInstruction (SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Material material) {
|
public static void GenerateSingleSubmeshInstruction (SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Material material) {
|
||||||
ExposedList<Slot> drawOrder = skeleton.drawOrder;
|
ExposedList<Slot> drawOrder = skeleton.drawOrder;
|
||||||
@ -295,7 +296,7 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (noRender) {
|
if (noRender) {
|
||||||
if (current.forceSeparate && current.rawVertexCount > 0 && generateMeshOverride) {
|
if (current.forceSeparate && generateMeshOverride && current.rawVertexCount > 0) {
|
||||||
{ // Add
|
{ // Add
|
||||||
current.endSlot = i;
|
current.endSlot = i;
|
||||||
current.preActiveClippingSlotSource = lastPreActiveClipping;
|
current.preActiveClippingSlotSource = lastPreActiveClipping;
|
||||||
@ -305,6 +306,7 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
submeshIndex++;
|
submeshIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
current.startSlot = i;
|
current.startSlot = i;
|
||||||
lastPreActiveClipping = clippingAttachmentSource;
|
lastPreActiveClipping = clippingAttachmentSource;
|
||||||
#if SPINE_TRIANGLECHECK
|
#if SPINE_TRIANGLECHECK
|
||||||
@ -327,7 +329,7 @@ namespace Spine.Unity {
|
|||||||
Material material = (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject;
|
Material material = (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (current.rawVertexCount > 0 && (current.forceSeparate || !System.Object.ReferenceEquals(current.material, material))) { // Material changed. Add the previous submesh.
|
if (current.forceSeparate || (current.rawVertexCount > 0 && !System.Object.ReferenceEquals(current.material, material))) { // Material changed. Add the previous submesh.
|
||||||
{ // Add
|
{ // Add
|
||||||
current.endSlot = i;
|
current.endSlot = i;
|
||||||
current.preActiveClippingSlotSource = lastPreActiveClipping;
|
current.preActiveClippingSlotSource = lastPreActiveClipping;
|
||||||
|
|||||||
@ -104,12 +104,18 @@ namespace Spine.Unity.Modules {
|
|||||||
|
|
||||||
// STEP 3: modify mesh.
|
// STEP 3: modify mesh.
|
||||||
var mesh = smartMesh.mesh;
|
var mesh = smartMesh.mesh;
|
||||||
meshGenerator.FillVertexData(mesh);
|
|
||||||
if (updateTriangles) {
|
if (meshGenerator.VertexCount <= 0) { // Clear an empty mesh
|
||||||
meshGenerator.FillTriangles(mesh);
|
updateTriangles = false;
|
||||||
meshRenderer.sharedMaterials = buffers.GetUpdatedShaderdMaterialsArray();
|
mesh.Clear();
|
||||||
} else if (buffers.MaterialsChangedInLastUpdate()) {
|
} else {
|
||||||
meshRenderer.sharedMaterials = buffers.GetUpdatedShaderdMaterialsArray();
|
meshGenerator.FillVertexData(mesh);
|
||||||
|
if (updateTriangles) {
|
||||||
|
meshGenerator.FillTriangles(mesh);
|
||||||
|
meshRenderer.sharedMaterials = buffers.GetUpdatedShaderdMaterialsArray();
|
||||||
|
} else if (buffers.MaterialsChangedInLastUpdate()) {
|
||||||
|
meshRenderer.sharedMaterials = buffers.GetUpdatedShaderdMaterialsArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
meshFilter.sharedMesh = mesh;
|
meshFilter.sharedMesh = mesh;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user