diff --git a/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs b/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs index 14efdeecf..2761a9a3f 100644 --- a/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs +++ b/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs @@ -73,6 +73,8 @@ namespace Spine.Unity { public int SlotCount { get { return endSlot - startSlot; } } } + public delegate void MeshGeneratorDelegate (MeshGenerator meshGenerator); + [System.Serializable] public class MeshGenerator { public Settings settings = Settings.Default; @@ -115,6 +117,10 @@ namespace Spine.Unity { [NonSerialized] readonly ExposedList colorBuffer = new ExposedList(4); [NonSerialized] readonly ExposedList> submeshes = new ExposedList> { new ExposedList(6) }; // start with 1 submesh. + public Vector3[] VertexBuffer { get { return this.vertexBuffer.Items; } } + public Vector2[] UVBuffer { get { return this.uvBuffer.Items; } } + public Color32[] ColorBuffer { get { return this.colorBuffer.Items; } } + [NonSerialized] Vector2 meshBoundsMin, meshBoundsMax; [NonSerialized] float meshBoundsThickness; [NonSerialized] int submeshIndex = 0; diff --git a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs b/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs index d65409b68..5fa0f4a99 100644 --- a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs +++ b/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs @@ -199,6 +199,9 @@ namespace Spine.Unity { public event UpdateBonesDelegate UpdateWorld; public event UpdateBonesDelegate UpdateComplete; + /// Occurs after the vertex data populated every frame, before the vertices are pushed into the mesh. + public event Spine.Unity.MeshGeneratorDelegate OnPostProcessVertices; + public void Clear () { skeleton = null; canvasRenderer.Clear(); @@ -269,11 +272,12 @@ namespace Spine.Unity { } if (canvas != null) meshGenerator.ScaleVertexData(canvas.referencePixelsPerUnit); + if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator); var mesh = smartMesh.mesh; meshGenerator.FillVertexData(mesh); if (updateTriangles) meshGenerator.FillTrianglesSingle(mesh); - + canvasRenderer.SetMesh(mesh); smartMesh.instructionUsed.Set(currentInstructions); diff --git a/spine-unity/Assets/spine-unity/SkeletonRenderer.cs b/spine-unity/Assets/spine-unity/SkeletonRenderer.cs index f69b2d8bf..cd5c51615 100644 --- a/spine-unity/Assets/spine-unity/SkeletonRenderer.cs +++ b/spine-unity/Assets/spine-unity/SkeletonRenderer.cs @@ -41,7 +41,10 @@ namespace Spine.Unity { public class SkeletonRenderer : MonoBehaviour, ISkeletonComponent { public delegate void SkeletonRendererDelegate (SkeletonRenderer skeletonRenderer); - public SkeletonRendererDelegate OnRebuild; + public event SkeletonRendererDelegate OnRebuild; + + /// Occurs after the vertex data is populated every frame, before the vertices are pushed into the mesh. + public event Spine.Unity.MeshGeneratorDelegate OnPostProcessVertices; public SkeletonDataAsset skeletonDataAsset; public SkeletonDataAsset SkeletonDataAsset { get { return skeletonDataAsset; } } // ISkeletonComponent @@ -280,6 +283,8 @@ namespace Spine.Unity { meshGenerator.BuildMeshWithArrays(currentInstructions, updateTriangles); } + if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator); + // STEP 3. Move the mesh data into a UnityEngine.Mesh =========================================================================== var currentMesh = currentSmartMesh.mesh; meshGenerator.FillVertexData(currentMesh);