mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Color -> Color32 in skeleton mesh generation
This commit is contained in:
parent
00b53ffa72
commit
3ce1298005
@ -11,20 +11,17 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
|
|||||||
|
|
||||||
private Mesh mesh;
|
private Mesh mesh;
|
||||||
private Vector3[] vertices;
|
private Vector3[] vertices;
|
||||||
private Color[] colors;
|
private Color32[] colors;
|
||||||
private Vector2[] uvs;
|
private Vector2[] uvs;
|
||||||
private int cachedQuadCount;
|
private int cachedQuadCount;
|
||||||
private float[] vertexPositions;
|
private float[] vertexPositions;
|
||||||
private List<Material> submeshMaterials = new List<Material>();
|
private List<Material> submeshMaterials = new List<Material>();
|
||||||
private List<int[]> submeshIndices = new List<int[]>();
|
private List<int[]> submeshIndices = new List<int[]>();
|
||||||
private Color cachedCurrentColor;
|
|
||||||
|
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
vertexPositions = new float[8];
|
vertexPositions = new float[8];
|
||||||
submeshMaterials = new List<Material>();
|
submeshMaterials = new List<Material>();
|
||||||
submeshIndices = new List<int[]>();
|
submeshIndices = new List<int[]>();
|
||||||
cachedCurrentColor = new Color();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start () {
|
void Start () {
|
||||||
@ -69,6 +66,7 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
|
|||||||
int quadIndex = 0;
|
int quadIndex = 0;
|
||||||
int drawCount = skeleton.DrawOrder.Count;
|
int drawCount = skeleton.DrawOrder.Count;
|
||||||
|
|
||||||
|
Color32 color = new Color32();
|
||||||
for (int i = 0; i < drawCount; i++) {
|
for (int i = 0; i < drawCount; i++) {
|
||||||
Slot slot = skeleton.DrawOrder[i];
|
Slot slot = skeleton.DrawOrder[i];
|
||||||
Attachment attachment = slot.Attachment;
|
Attachment attachment = slot.Attachment;
|
||||||
@ -90,15 +88,15 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
|
|||||||
uvs[vertexIndex + 2] = new Vector2(regionUVs[RegionAttachment.X2],regionUVs[RegionAttachment.Y2]);
|
uvs[vertexIndex + 2] = new Vector2(regionUVs[RegionAttachment.X2],regionUVs[RegionAttachment.Y2]);
|
||||||
uvs[vertexIndex + 3] = new Vector2(regionUVs[RegionAttachment.X3],regionUVs[RegionAttachment.Y3]);
|
uvs[vertexIndex + 3] = new Vector2(regionUVs[RegionAttachment.X3],regionUVs[RegionAttachment.Y3]);
|
||||||
|
|
||||||
cachedCurrentColor.a = skeleton.A * slot.A;
|
color.a = (byte)(skeleton.A * slot.A * 255);
|
||||||
cachedCurrentColor.r = skeleton.R * slot.R * slot.A;
|
color.r = (byte)(skeleton.R * slot.R * color.a);
|
||||||
cachedCurrentColor.g = skeleton.G * slot.G * slot.A;
|
color.g = (byte)(skeleton.G * slot.G * color.a);
|
||||||
cachedCurrentColor.b = skeleton.B * slot.B * slot.A;
|
color.b = (byte)(skeleton.B * slot.B * color.a);
|
||||||
|
|
||||||
colors[vertexIndex] = cachedCurrentColor;
|
colors[vertexIndex] = color;
|
||||||
colors[vertexIndex + 1] = cachedCurrentColor;
|
colors[vertexIndex + 1] = color;
|
||||||
colors[vertexIndex + 2] = cachedCurrentColor;
|
colors[vertexIndex + 2] = color;
|
||||||
colors[vertexIndex + 3] = cachedCurrentColor;
|
colors[vertexIndex + 3] = color;
|
||||||
|
|
||||||
quadIndex++;
|
quadIndex++;
|
||||||
}
|
}
|
||||||
@ -107,7 +105,7 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
|
|||||||
mesh.Clear();
|
mesh.Clear();
|
||||||
|
|
||||||
mesh.vertices = vertices;
|
mesh.vertices = vertices;
|
||||||
mesh.colors = colors;
|
mesh.colors32 = colors;
|
||||||
mesh.uv = uvs;
|
mesh.uv = uvs;
|
||||||
|
|
||||||
mesh.subMeshCount = submeshIndices.Count;
|
mesh.subMeshCount = submeshIndices.Count;
|
||||||
@ -142,7 +140,7 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
|
|||||||
cachedQuadCount = quadCount;
|
cachedQuadCount = quadCount;
|
||||||
vertices = new Vector3[quadCount * 4];
|
vertices = new Vector3[quadCount * 4];
|
||||||
uvs = new Vector2[quadCount * 4];
|
uvs = new Vector2[quadCount * 4];
|
||||||
colors = new Color[quadCount * 4];
|
colors = new Color32[quadCount * 4];
|
||||||
|
|
||||||
UpdateSubmeshCache();
|
UpdateSubmeshCache();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user