mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 23:34:53 +08:00
[unity] Add vertex effect callback.
This commit is contained in:
parent
9cd0167a03
commit
14e718d0d3
@ -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<Color32> colorBuffer = new ExposedList<Color32>(4);
|
||||
[NonSerialized] readonly ExposedList<ExposedList<int>> submeshes = new ExposedList<ExposedList<int>> { new ExposedList<int>(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;
|
||||
|
||||
@ -199,6 +199,9 @@ namespace Spine.Unity {
|
||||
public event UpdateBonesDelegate UpdateWorld;
|
||||
public event UpdateBonesDelegate UpdateComplete;
|
||||
|
||||
/// <summary> Occurs after the vertex data populated every frame, before the vertices are pushed into the mesh.</summary>
|
||||
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);
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
/// <summary> Occurs after the vertex data is populated every frame, before the vertices are pushed into the mesh.</summary>
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user