[unity] Match changes in spine-csharp 3.6

This commit is contained in:
pharan 2017-02-27 00:38:26 +08:00
parent 9b302de4ff
commit 757006f199
5 changed files with 24 additions and 18 deletions

View File

@ -543,7 +543,7 @@ namespace Spine.Unity.Editor {
Vector2[] uvs = ExtractUV(attachment.UVs); Vector2[] uvs = ExtractUV(attachment.UVs);
float[] floatVerts = new float[8]; float[] floatVerts = new float[8];
attachment.ComputeWorldVertices(bone, floatVerts); attachment.ComputeWorldVertices(bone, floatVerts, 0);
Vector3[] verts = ExtractVerts(floatVerts); Vector3[] verts = ExtractVerts(floatVerts);
//unrotate verts now that they're centered //unrotate verts now that they're centered

View File

@ -914,6 +914,10 @@ namespace Spine.Unity.Editor {
public PathAttachment NewPathAttachment (Skin skin, string name) { public PathAttachment NewPathAttachment (Skin skin, string name) {
return new PathAttachment(name); return new PathAttachment(name);
} }
public PointAttachment NewPointAttachment (Skin skin, string name) {
return new PointAttachment(name);
}
} }
#endregion #endregion
@ -1165,7 +1169,7 @@ namespace Spine.Unity.Editor {
#endregion #endregion
#region Checking Methods #region Checking Methods
static int[][] compatibleVersions = { new[] {3, 5, 0} }; static int[][] compatibleVersions = { new[] {3, 6, 0} };
//static bool isFixVersionRequired = false; //static bool isFixVersionRequired = false;
static bool CheckForValidSkeletonData (string skeletonJSONPath) { static bool CheckForValidSkeletonData (string skeletonJSONPath) {

View File

@ -130,12 +130,12 @@ namespace Spine.Unity.MeshGeneration {
var regionAttachment = attachment as RegionAttachment; var regionAttachment = attachment as RegionAttachment;
if (regionAttachment != null) { if (regionAttachment != null) {
regionAttachment.ComputeWorldVertices(slot.bone, tempVerts); regionAttachment.ComputeWorldVertices(slot.bone, tempVerts, 0);
float x1 = tempVerts[RegionAttachment.X1], y1 = tempVerts[RegionAttachment.Y1]; float x1 = tempVerts[RegionAttachment.BLX], y1 = tempVerts[RegionAttachment.BLY];
float x2 = tempVerts[RegionAttachment.X2], y2 = tempVerts[RegionAttachment.Y2]; float x2 = tempVerts[RegionAttachment.ULX], y2 = tempVerts[RegionAttachment.ULY];
float x3 = tempVerts[RegionAttachment.X3], y3 = tempVerts[RegionAttachment.Y3]; float x3 = tempVerts[RegionAttachment.URX], y3 = tempVerts[RegionAttachment.URY];
float x4 = tempVerts[RegionAttachment.X4], y4 = tempVerts[RegionAttachment.Y4]; float x4 = tempVerts[RegionAttachment.BRX], y4 = tempVerts[RegionAttachment.BRY];
verts[vi].x = x1; verts[vi].y = y1; verts[vi].z = z; verts[vi].x = x1; verts[vi].y = y1; verts[vi].z = z;
verts[vi + 1].x = x4; verts[vi + 1].y = y4; verts[vi + 1].z = z; verts[vi + 1].x = x4; verts[vi + 1].y = y4; verts[vi + 1].z = z;
verts[vi + 2].x = x2; verts[vi + 2].y = y2; verts[vi + 2].z = z; verts[vi + 2].x = x2; verts[vi + 2].y = y2; verts[vi + 2].z = z;
@ -146,7 +146,7 @@ namespace Spine.Unity.MeshGeneration {
color.r = (byte)(r * slot.r * regionAttachment.r * color.a); color.r = (byte)(r * slot.r * regionAttachment.r * color.a);
color.g = (byte)(g * slot.g * regionAttachment.g * color.a); color.g = (byte)(g * slot.g * regionAttachment.g * color.a);
color.b = (byte)(b * slot.b * regionAttachment.b * color.a); color.b = (byte)(b * slot.b * regionAttachment.b * color.a);
if (slot.data.blendMode == BlendMode.additive) color.a = 0; if (slot.data.blendMode == BlendMode.Additive) color.a = 0;
} else { } else {
color.a = (byte)(a * slot.a * regionAttachment.a); color.a = (byte)(a * slot.a * regionAttachment.a);
color.r = (byte)(r * slot.r * regionAttachment.r * 255); color.r = (byte)(r * slot.r * regionAttachment.r * 255);
@ -157,10 +157,10 @@ namespace Spine.Unity.MeshGeneration {
colors[vi] = color; colors[vi + 1] = color; colors[vi + 2] = color; colors[vi + 3] = color; colors[vi] = color; colors[vi + 1] = color; colors[vi + 2] = color; colors[vi + 3] = color;
float[] regionUVs = regionAttachment.uvs; float[] regionUVs = regionAttachment.uvs;
uvs[vi].x = regionUVs[RegionAttachment.X1]; uvs[vi].y = regionUVs[RegionAttachment.Y1]; uvs[vi].x = regionUVs[RegionAttachment.BLX]; uvs[vi].y = regionUVs[RegionAttachment.BLY];
uvs[vi + 1].x = regionUVs[RegionAttachment.X4]; uvs[vi + 1].y = regionUVs[RegionAttachment.Y4]; uvs[vi + 1].x = regionUVs[RegionAttachment.BRX]; uvs[vi + 1].y = regionUVs[RegionAttachment.BRY];
uvs[vi + 2].x = regionUVs[RegionAttachment.X2]; uvs[vi + 2].y = regionUVs[RegionAttachment.Y2]; uvs[vi + 2].x = regionUVs[RegionAttachment.ULX]; uvs[vi + 2].y = regionUVs[RegionAttachment.ULY];
uvs[vi + 3].x = regionUVs[RegionAttachment.X3]; uvs[vi + 3].y = regionUVs[RegionAttachment.Y3]; uvs[vi + 3].x = regionUVs[RegionAttachment.URX]; uvs[vi + 3].y = regionUVs[RegionAttachment.URY];
if (x1 < bmin.x) bmin.x = x1; // Potential first attachment bounds initialization. Initial min should not block initial max. Same for Y below. if (x1 < bmin.x) bmin.x = x1; // Potential first attachment bounds initialization. Initial min should not block initial max. Same for Y below.
if (x1 > bmax.x) bmax.x = x1; if (x1 > bmax.x) bmax.x = x1;
@ -193,7 +193,7 @@ namespace Spine.Unity.MeshGeneration {
color.r = (byte)(r * slot.r * meshAttachment.r * color.a); color.r = (byte)(r * slot.r * meshAttachment.r * color.a);
color.g = (byte)(g * slot.g * meshAttachment.g * color.a); color.g = (byte)(g * slot.g * meshAttachment.g * color.a);
color.b = (byte)(b * slot.b * meshAttachment.b * color.a); color.b = (byte)(b * slot.b * meshAttachment.b * color.a);
if (slot.data.blendMode == BlendMode.additive) color.a = 0; if (slot.data.blendMode == BlendMode.Additive) color.a = 0;
} else { } else {
color.a = (byte)(a * slot.a * meshAttachment.a); color.a = (byte)(a * slot.a * meshAttachment.a);
color.r = (byte)(r * slot.r * meshAttachment.r * 255); color.r = (byte)(r * slot.r * meshAttachment.r * 255);

View File

@ -341,6 +341,8 @@ namespace Spine.Unity.Modules.AttachmentTools {
return Sprite.Create(ar.GetMainTexture(), ar.GetUnityRect(), new Vector2(0.5f, 0.5f), pixelsPerUnit); return Sprite.Create(ar.GetMainTexture(), ar.GetUnityRect(), new Vector2(0.5f, 0.5f), pixelsPerUnit);
} }
/// <summary>Creates a new Texture2D object based on an AtlasRegion.
/// If applyImmediately is true, Texture2D.Apply is called immediately after the Texture2D is filled with data.</summary>
public static Texture2D ToTexture (this AtlasRegion ar, bool applyImmediately = true) { public static Texture2D ToTexture (this AtlasRegion ar, bool applyImmediately = true) {
Texture2D sourceTexture = ar.GetMainTexture(); Texture2D sourceTexture = ar.GetMainTexture();
Rect r = ar.GetUnityRect(sourceTexture.height); Rect r = ar.GetUnityRect(sourceTexture.height);
@ -657,9 +659,9 @@ namespace Spine.Unity.Modules.AttachmentTools {
}; };
// Linked mesh // Linked mesh
if (o.parentMesh != null) { if (o.ParentMesh != null) {
// bones, vertices, worldVerticesLength, regionUVs, triangles, HullLength, Edges, Width, Height // bones, vertices, worldVerticesLength, regionUVs, triangles, HullLength, Edges, Width, Height
ma.ParentMesh = o.parentMesh; ma.ParentMesh = o.ParentMesh;
} else { } else {
CloneVertexAttachment(o, ma); // bones, vertices, worldVerticesLength CloneVertexAttachment(o, ma); // bones, vertices, worldVerticesLength
ma.regionUVs = o.regionUVs.Clone() as float[]; ma.regionUVs = o.regionUVs.Clone() as float[];
@ -704,8 +706,8 @@ namespace Spine.Unity.Modules.AttachmentTools {
if (region == null) throw new System.ArgumentNullException("region"); if (region == null) throw new System.ArgumentNullException("region");
// If parentMesh is a linked mesh, create a link to its parent. Preserves Deform animations. // If parentMesh is a linked mesh, create a link to its parent. Preserves Deform animations.
if (o.parentMesh != null) if (o.ParentMesh != null)
o = o.parentMesh; o = o.ParentMesh;
// 1. NewMeshAttachment (AtlasAttachmentLoader.cs) // 1. NewMeshAttachment (AtlasAttachmentLoader.cs)
var mesh = new MeshAttachment(newLinkedMeshName); var mesh = new MeshAttachment(newLinkedMeshName);

View File

@ -1 +1 @@
This Spine-Unity runtime works with data exported from Spine Editor version: 3.5.xx This Spine-Unity runtime works with data exported from Spine Editor version: 3.6.xx