mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +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 int SlotCount { get { return endSlot - startSlot; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public delegate void MeshGeneratorDelegate (MeshGenerator meshGenerator);
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class MeshGenerator {
|
public class MeshGenerator {
|
||||||
public Settings settings = Settings.Default;
|
public Settings settings = Settings.Default;
|
||||||
@ -115,6 +117,10 @@ namespace Spine.Unity {
|
|||||||
[NonSerialized] readonly ExposedList<Color32> colorBuffer = new ExposedList<Color32>(4);
|
[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.
|
[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] Vector2 meshBoundsMin, meshBoundsMax;
|
||||||
[NonSerialized] float meshBoundsThickness;
|
[NonSerialized] float meshBoundsThickness;
|
||||||
[NonSerialized] int submeshIndex = 0;
|
[NonSerialized] int submeshIndex = 0;
|
||||||
|
|||||||
@ -199,6 +199,9 @@ namespace Spine.Unity {
|
|||||||
public event UpdateBonesDelegate UpdateWorld;
|
public event UpdateBonesDelegate UpdateWorld;
|
||||||
public event UpdateBonesDelegate UpdateComplete;
|
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 () {
|
public void Clear () {
|
||||||
skeleton = null;
|
skeleton = null;
|
||||||
canvasRenderer.Clear();
|
canvasRenderer.Clear();
|
||||||
@ -269,6 +272,7 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canvas != null) meshGenerator.ScaleVertexData(canvas.referencePixelsPerUnit);
|
if (canvas != null) meshGenerator.ScaleVertexData(canvas.referencePixelsPerUnit);
|
||||||
|
if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator);
|
||||||
|
|
||||||
var mesh = smartMesh.mesh;
|
var mesh = smartMesh.mesh;
|
||||||
meshGenerator.FillVertexData(mesh);
|
meshGenerator.FillVertexData(mesh);
|
||||||
|
|||||||
@ -41,7 +41,10 @@ namespace Spine.Unity {
|
|||||||
public class SkeletonRenderer : MonoBehaviour, ISkeletonComponent {
|
public class SkeletonRenderer : MonoBehaviour, ISkeletonComponent {
|
||||||
|
|
||||||
public delegate void SkeletonRendererDelegate (SkeletonRenderer skeletonRenderer);
|
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;
|
||||||
public SkeletonDataAsset SkeletonDataAsset { get { return skeletonDataAsset; } } // ISkeletonComponent
|
public SkeletonDataAsset SkeletonDataAsset { get { return skeletonDataAsset; } } // ISkeletonComponent
|
||||||
@ -280,6 +283,8 @@ namespace Spine.Unity {
|
|||||||
meshGenerator.BuildMeshWithArrays(currentInstructions, updateTriangles);
|
meshGenerator.BuildMeshWithArrays(currentInstructions, updateTriangles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OnPostProcessVertices != null) OnPostProcessVertices.Invoke(this.meshGenerator);
|
||||||
|
|
||||||
// STEP 3. Move the mesh data into a UnityEngine.Mesh ===========================================================================
|
// STEP 3. Move the mesh data into a UnityEngine.Mesh ===========================================================================
|
||||||
var currentMesh = currentSmartMesh.mesh;
|
var currentMesh = currentSmartMesh.mesh;
|
||||||
meshGenerator.FillVertexData(currentMesh);
|
meshGenerator.FillVertexData(currentMesh);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user