mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Fixed slot colors.
This commit is contained in:
parent
4b9b17e190
commit
e0fffa79b3
@ -39,6 +39,7 @@ public class SkeletonComponent : MonoBehaviour {
|
||||
public Spine.AnimationState state;
|
||||
private Mesh mesh;
|
||||
private Vector3[] vertices;
|
||||
private Color[] colors;
|
||||
private Vector2[] uvs;
|
||||
private int[] triangles;
|
||||
private int quadCount;
|
||||
@ -117,6 +118,7 @@ public class SkeletonComponent : MonoBehaviour {
|
||||
if (quadCount != this.quadCount) {
|
||||
this.quadCount = quadCount;
|
||||
vertices = new Vector3[quadCount * 4];
|
||||
colors = new Color[quadCount * 4];
|
||||
uvs = new Vector2[quadCount * 4];
|
||||
triangles = new int[quadCount * 6];
|
||||
mesh.Clear();
|
||||
@ -124,6 +126,7 @@ public class SkeletonComponent : MonoBehaviour {
|
||||
|
||||
// Setup mesh.
|
||||
int quadIndex = 0;
|
||||
Color color = new Color();
|
||||
for (int i = 0, n = drawOrder.Count; i < n; i++) {
|
||||
Slot slot = drawOrder[i];
|
||||
Attachment attachment = slot.Attachment;
|
||||
@ -138,6 +141,15 @@ public class SkeletonComponent : MonoBehaviour {
|
||||
vertices[vertexIndex + 2] = new Vector3(regionVertices[RegionAttachment.X2], regionVertices[RegionAttachment.Y2], 0);
|
||||
vertices[vertexIndex + 3] = new Vector3(regionVertices[RegionAttachment.X3], regionVertices[RegionAttachment.Y3], 0);
|
||||
|
||||
color.r = skeleton.R * slot.R;
|
||||
color.g = skeleton.G * slot.G;
|
||||
color.b = skeleton.B * slot.B;
|
||||
color.a = skeleton.A * slot.A;
|
||||
colors[vertexIndex] = color;
|
||||
colors[vertexIndex + 1] = color;
|
||||
colors[vertexIndex + 2] = color;
|
||||
colors[vertexIndex + 3] = color;
|
||||
|
||||
float[] regionUVs = regionAttachment.UVs;
|
||||
uvs[vertexIndex] = new Vector2(regionUVs[RegionAttachment.X1], 1 - regionUVs[RegionAttachment.Y1]);
|
||||
uvs[vertexIndex + 1] = new Vector2(regionUVs[RegionAttachment.X4], 1 - regionUVs[RegionAttachment.Y4]);
|
||||
@ -156,6 +168,7 @@ public class SkeletonComponent : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
mesh.vertices = vertices;
|
||||
mesh.colors = colors;
|
||||
mesh.uv = uvs;
|
||||
mesh.triangles = triangles;
|
||||
|
||||
|
||||
@ -9,8 +9,9 @@ Shader "Skeleton" {
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
Pass {
|
||||
ColorMaterial AmbientAndDiffuse
|
||||
SetTexture [_MainTex] {
|
||||
combine texture
|
||||
combine texture * primary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
4
spine-unity/Assets/examples/Unity 4.meta
Normal file
4
spine-unity/Assets/examples/Unity 4.meta
Normal file
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c42e48410176c3b43ac8ba8fbb1256d2
|
||||
DefaultImporter:
|
||||
userData:
|
||||
Loading…
x
Reference in New Issue
Block a user