mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Fixed spine-unity, spine-tk2d.
This commit is contained in:
parent
8e4f1e5f49
commit
5390d40093
@ -212,7 +212,7 @@ namespace Spine {
|
|||||||
List<Object> values = (List<Object>)map["vertices"];
|
List<Object> values = (List<Object>)map["vertices"];
|
||||||
float[] vertices = new float[values.Count];
|
float[] vertices = new float[values.Count];
|
||||||
for (int i = 0, n = values.Count; i < n; i++)
|
for (int i = 0, n = values.Count; i < n; i++)
|
||||||
vertices[i] = (float)values[i] * scale;
|
vertices[i] = (float)values[i] * Scale;
|
||||||
boundingBox.Vertices = vertices;
|
boundingBox.Vertices = vertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public class SkeletonAnimation : SkeletonComponent {
|
|||||||
TrackEntry entry = state.GetCurrent(0);
|
TrackEntry entry = state.GetCurrent(0);
|
||||||
if (animationName == null || animationName.Length == 0) {
|
if (animationName == null || animationName.Length == 0) {
|
||||||
if (entry != null && entry.Animation != null)
|
if (entry != null && entry.Animation != null)
|
||||||
state.Clear(0);
|
state.ClearTrack(0);
|
||||||
} else if (entry == null || entry.Animation == null || animationName != entry.Animation.Name) {
|
} else if (entry == null || entry.Animation == null || animationName != entry.Animation.Name) {
|
||||||
Spine.Animation animation = skeleton.Data.FindAnimation(animationName);
|
Spine.Animation animation = skeleton.Data.FindAnimation(animationName);
|
||||||
if (animation != null)
|
if (animation != null)
|
||||||
|
|||||||
@ -89,10 +89,14 @@ public class SkeletonComponent : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update () {
|
public virtual void Update () {
|
||||||
|
if (skeletonDataAsset == null) {
|
||||||
|
Clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(false);
|
SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(false);
|
||||||
|
|
||||||
// Clear fields if missing information to render.
|
if (skeletonData == null) {
|
||||||
if (skeletonDataAsset == null || skeletonData == null) {
|
|
||||||
Clear();
|
Clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -193,7 +197,7 @@ public class SkeletonComponent : MonoBehaviour {
|
|||||||
mesh.uv = uvs;
|
mesh.uv = uvs;
|
||||||
|
|
||||||
mesh.subMeshCount = submeshMaterials.Count;
|
mesh.subMeshCount = submeshMaterials.Count;
|
||||||
for (int i = 0; i < mesh.subMeshCount; ++i)
|
for (int i = 0, n = mesh.subMeshCount; i < n; ++i)
|
||||||
mesh.SetTriangles(submeshIndexes[i], i);
|
mesh.SetTriangles(submeshIndexes[i], i);
|
||||||
|
|
||||||
if (calculateNormals) {
|
if (calculateNormals) {
|
||||||
@ -201,10 +205,11 @@ public class SkeletonComponent : MonoBehaviour {
|
|||||||
if (calculateTangents) {
|
if (calculateTangents) {
|
||||||
Vector4[] tangents = this.tangents;
|
Vector4[] tangents = this.tangents;
|
||||||
int count = mesh.normals.Length;
|
int count = mesh.normals.Length;
|
||||||
if (tangents.Length != count)
|
if (tangents.Length != count) {
|
||||||
this.tangents = tangents = new Vector4[count];
|
this.tangents = tangents = new Vector4[count];
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
tangents[i] = new Vector4(1, 0, 0, 1);
|
tangents[i] = new Vector4(1, 0, 0, 1);
|
||||||
|
}
|
||||||
mesh.tangents = tangents;
|
mesh.tangents = tangents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,7 +235,6 @@ public class SkeletonComponent : MonoBehaviour {
|
|||||||
} else {
|
} else {
|
||||||
if (indexes.Length >= indexCount) { // Allow last submesh to have more indices than required.
|
if (indexes.Length >= indexCount) { // Allow last submesh to have more indices than required.
|
||||||
if (submeshFirstVertex[submeshIndex] == vertexIndex) return;
|
if (submeshFirstVertex[submeshIndex] == vertexIndex) return;
|
||||||
indexCount = indexes.Length; // Update vertices to the end.
|
|
||||||
} else
|
} else
|
||||||
submeshIndexes[submeshIndex] = indexes = new int[indexCount];
|
submeshIndexes[submeshIndex] = indexes = new int[indexCount];
|
||||||
}
|
}
|
||||||
@ -250,6 +254,12 @@ public class SkeletonComponent : MonoBehaviour {
|
|||||||
indexes[i + 4] = vertexIndex + 3;
|
indexes[i + 4] = vertexIndex + 3;
|
||||||
indexes[i + 5] = vertexIndex + 1;
|
indexes[i + 5] = vertexIndex + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastSubmesh) {
|
||||||
|
// Update vertices to the end.
|
||||||
|
for (int i = indexCount, n = indexes.Length; i < n; i++)
|
||||||
|
indexes[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnEnable () {
|
public virtual void OnEnable () {
|
||||||
|
|||||||
@ -47,8 +47,14 @@ public class SpriteCollectionAttachmentLoader : AttachmentLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Attachment NewAttachment (Skin skin, AttachmentType type, String name) {
|
public Attachment NewAttachment (Skin skin, AttachmentType type, String name) {
|
||||||
if (type != AttachmentType.region)
|
switch (type) {
|
||||||
|
case AttachmentType.region:
|
||||||
|
break;
|
||||||
|
case AttachmentType.boundingbox:
|
||||||
|
return new BoundingBoxAttachment(name);
|
||||||
|
default:
|
||||||
throw new Exception("Unknown attachment type: " + type);
|
throw new Exception("Unknown attachment type: " + type);
|
||||||
|
}
|
||||||
|
|
||||||
// Strip folder names.
|
// Strip folder names.
|
||||||
int index = name.LastIndexOfAny(new char[] {'/', '\\'});
|
int index = name.LastIndexOfAny(new char[] {'/', '\\'});
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public class SkeletonAnimation : SkeletonComponent {
|
|||||||
TrackEntry entry = state.GetCurrent(0);
|
TrackEntry entry = state.GetCurrent(0);
|
||||||
if (animationName == null || animationName.Length == 0) {
|
if (animationName == null || animationName.Length == 0) {
|
||||||
if (entry != null && entry.Animation != null)
|
if (entry != null && entry.Animation != null)
|
||||||
state.Clear(0);
|
state.ClearTrack(0);
|
||||||
} else if (entry == null || entry.Animation == null || animationName != entry.Animation.Name) {
|
} else if (entry == null || entry.Animation == null || animationName != entry.Animation.Name) {
|
||||||
Spine.Animation animation = skeleton.Data.FindAnimation(animationName);
|
Spine.Animation animation = skeleton.Data.FindAnimation(animationName);
|
||||||
if (animation != null)
|
if (animation != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user