mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Updated spine-unity for Spine v3.
@Fenrisul she's ready for your magic! :D See diff and/or `// MITCH` comments. @pharan
This commit is contained in:
parent
08b74f5b18
commit
4283d6fce3
2
.gitignore
vendored
2
.gitignore
vendored
@ -60,6 +60,8 @@ spine-xna/example/obj
|
||||
|
||||
spine-unity/Assets/spine-csharp*
|
||||
!spine-unity/Assets/spine-csharp/Place spine-csharp src here.*
|
||||
spine-unity/spine-unity.CSharp.csproj
|
||||
spine-unity/spine-unity.CSharp.Editor.csproj
|
||||
spine-unity/ProjectSettings
|
||||
spine-unity/Temp
|
||||
spine-unity/Library
|
||||
|
||||
@ -125,7 +125,7 @@ public class BoneFollower : MonoBehaviour {
|
||||
|
||||
if (followBoneRotation) {
|
||||
Vector3 rotation = cachedTransform.localRotation.eulerAngles;
|
||||
cachedTransform.localRotation = Quaternion.Euler(rotation.x, rotation.y, bone.worldRotation * flipRotation);
|
||||
cachedTransform.localRotation = Quaternion.Euler(rotation.x, rotation.y, bone.WorldRotationX * flipRotation);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -138,7 +138,7 @@ public class BoneFollower : MonoBehaviour {
|
||||
if (followBoneRotation) {
|
||||
Vector3 rotation = skeletonTransform.rotation.eulerAngles;
|
||||
|
||||
cachedTransform.rotation = Quaternion.Euler(rotation.x, rotation.y, skeletonTransform.rotation.eulerAngles.z + (bone.worldRotation * flipRotation));
|
||||
cachedTransform.rotation = Quaternion.Euler(rotation.x, rotation.y, skeletonTransform.rotation.eulerAngles.z + (bone.WorldRotationX * flipRotation));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -266,13 +266,13 @@ public static class SkeletonBaker {
|
||||
unusedMeshNames.Remove(attachmentMeshName);
|
||||
if (newPrefab || meshTable.ContainsKey(attachmentMeshName) == false)
|
||||
AssetDatabase.AddObjectToAsset(mesh, prefab);
|
||||
} else if (attachment is SkinnedMeshAttachment) {
|
||||
var meshAttachment = (SkinnedMeshAttachment)attachment;
|
||||
} else if (attachment is WeightedMeshAttachment) {
|
||||
var meshAttachment = (WeightedMeshAttachment)attachment;
|
||||
offset.x = 0;
|
||||
offset.y = 0;
|
||||
rotation = 0;
|
||||
mesh = ExtractSkinnedMeshAttachment(attachmentMeshName, meshAttachment, i, skeletonData, boneList, mesh);
|
||||
material = ExtractMaterial((SkinnedMeshAttachment)attachment);
|
||||
material = ExtractMaterial((WeightedMeshAttachment)attachment);
|
||||
unusedMeshNames.Remove(attachmentMeshName);
|
||||
if (newPrefab || meshTable.ContainsKey(attachmentMeshName) == false)
|
||||
AssetDatabase.AddObjectToAsset(mesh, prefab);
|
||||
@ -285,7 +285,7 @@ public static class SkeletonBaker {
|
||||
attachmentTransform.localPosition = offset;
|
||||
attachmentTransform.localRotation = Quaternion.Euler(0, 0, rotation);
|
||||
|
||||
if (attachment is SkinnedMeshAttachment) {
|
||||
if (attachment is WeightedMeshAttachment) {
|
||||
attachmentTransform.position = Vector3.zero;
|
||||
attachmentTransform.rotation = Quaternion.identity;
|
||||
var skinnedMeshRenderer = attachmentTransform.gameObject.AddComponent<SkinnedMeshRenderer>();
|
||||
@ -500,8 +500,8 @@ public static class SkeletonBaker {
|
||||
} else if (attachment is MeshAttachment) {
|
||||
var att = (MeshAttachment)attachment;
|
||||
return (Material)((AtlasRegion)att.RendererObject).page.rendererObject;
|
||||
} else if (attachment is SkinnedMeshAttachment) {
|
||||
var att = (SkinnedMeshAttachment)attachment;
|
||||
} else if (attachment is WeightedMeshAttachment) {
|
||||
var att = (WeightedMeshAttachment)attachment;
|
||||
return (Material)((AtlasRegion)att.RendererObject).page.rendererObject;
|
||||
} else {
|
||||
return null;
|
||||
@ -609,7 +609,7 @@ public static class SkeletonBaker {
|
||||
}
|
||||
}
|
||||
|
||||
static Mesh ExtractSkinnedMeshAttachment (string name, SkinnedMeshAttachment attachment, int slotIndex, SkeletonData skeletonData, List<Transform> boneList, Mesh mesh = null) {
|
||||
static Mesh ExtractSkinnedMeshAttachment (string name, WeightedMeshAttachment attachment, int slotIndex, SkeletonData skeletonData, List<Transform> boneList, Mesh mesh = null) {
|
||||
|
||||
Skeleton skeleton = new Skeleton(skeletonData);
|
||||
skeleton.UpdateWorldTransform();
|
||||
@ -949,10 +949,10 @@ public static class SkeletonBaker {
|
||||
static float GetUninheritedRotation (Bone b) {
|
||||
|
||||
Bone parent = b.Parent;
|
||||
float angle = b.RotationIK;
|
||||
float angle = b.AppliedRotation;
|
||||
|
||||
while (parent != null) {
|
||||
angle -= parent.RotationIK;
|
||||
angle -= parent.AppliedRotation;
|
||||
parent = parent.Parent;
|
||||
}
|
||||
|
||||
@ -971,7 +971,7 @@ public static class SkeletonBaker {
|
||||
|
||||
List<Keyframe> keys = new List<Keyframe>();
|
||||
|
||||
float rotation = bone.RotationIK;
|
||||
float rotation = bone.AppliedRotation;
|
||||
if (!inheritRotation)
|
||||
rotation = GetUninheritedRotation(bone);
|
||||
|
||||
@ -1002,7 +1002,7 @@ public static class SkeletonBaker {
|
||||
pk = keys[pIndex];
|
||||
|
||||
if (inheritRotation)
|
||||
rotation = bone.RotationIK;
|
||||
rotation = bone.AppliedRotation;
|
||||
else {
|
||||
rotation = GetUninheritedRotation(bone);
|
||||
}
|
||||
|
||||
@ -394,7 +394,7 @@ public class SkeletonDataAssetInspector : Editor {
|
||||
icon = SpineEditorUtilities.Icons.mesh;
|
||||
else if (type == typeof(BoundingBoxAttachment))
|
||||
icon = SpineEditorUtilities.Icons.boundingBox;
|
||||
else if (type == typeof(SkinnedMeshAttachment))
|
||||
else if (type == typeof(WeightedMeshAttachment))
|
||||
icon = SpineEditorUtilities.Icons.weights;
|
||||
else
|
||||
icon = SpineEditorUtilities.Icons.warning;
|
||||
|
||||
@ -1192,9 +1192,9 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
||||
return new MeshAttachment(name);
|
||||
}
|
||||
|
||||
public SkinnedMeshAttachment NewSkinnedMeshAttachment (Skin skin, string name, string path) {
|
||||
public WeightedMeshAttachment NewWeightedMeshAttachment(Skin skin, string name, string path) {
|
||||
requirementList.Add(path);
|
||||
return new SkinnedMeshAttachment(name);
|
||||
return new WeightedMeshAttachment(name);
|
||||
}
|
||||
|
||||
public BoundingBoxAttachment NewBoundingBoxAttachment (Skin skin, string name) {
|
||||
|
||||
@ -264,8 +264,10 @@ public class SkeletonRagdoll : MonoBehaviour {
|
||||
t.parent = transform;
|
||||
|
||||
t.localPosition = new Vector3(b.WorldX, b.WorldY, 0);
|
||||
t.localRotation = Quaternion.Euler(0, 0, b.WorldFlipX ^ b.WorldFlipY ? -b.WorldRotation : b.WorldRotation);
|
||||
t.localScale = new Vector3(b.WorldScaleX, b.WorldScaleY, 1);
|
||||
// MITCH
|
||||
// t.localRotation = Quaternion.Euler(0, 0, b.WorldFlipX ^ b.WorldFlipY ? -b.WorldRotation : b.WorldRotation);
|
||||
t.localRotation = Quaternion.Euler(0, 0, b.WorldRotationX);
|
||||
t.localScale = new Vector3(b.WorldScaleX, b.WorldScaleY, 1);
|
||||
|
||||
float length = b.Data.Length;
|
||||
|
||||
@ -282,8 +284,10 @@ public class SkeletonRagdoll : MonoBehaviour {
|
||||
if (colliders.Count == 0) {
|
||||
var box = go.AddComponent<BoxCollider>();
|
||||
box.size = new Vector3(length, thickness, thickness);
|
||||
box.center = new Vector3((b.WorldFlipX ? -length : length) / 2, 0);
|
||||
}
|
||||
// MITCH
|
||||
// box.center = new Vector3((b.WorldFlipX ? -length : length) / 2, 0);
|
||||
box.center = new Vector3(length / 2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
var rb = go.AddComponent<Rigidbody>();
|
||||
@ -302,10 +306,13 @@ public class SkeletonRagdoll : MonoBehaviour {
|
||||
if (skin == null)
|
||||
skin = skeleton.Data.DefaultSkin;
|
||||
|
||||
bool flipX = b.WorldFlipX;
|
||||
bool flipY = b.WorldFlipY;
|
||||
// MITCH
|
||||
// bool flipX = b.WorldFlipX;
|
||||
// bool flipY = b.WorldFlipY;
|
||||
bool flipX = false;
|
||||
bool flipY = false;
|
||||
|
||||
List<Attachment> attachments = new List<Attachment>();
|
||||
List<Attachment> attachments = new List<Attachment>();
|
||||
foreach (Slot s in skeleton.Slots) {
|
||||
if (s.Bone == b) {
|
||||
skin.FindAttachmentsForSlot(skeleton.Slots.IndexOf(s), attachments);
|
||||
@ -345,7 +352,7 @@ public class SkeletonRagdoll : MonoBehaviour {
|
||||
foreach (var pair in boneTable) {
|
||||
var b = pair.Key;
|
||||
var t = pair.Value;
|
||||
bool flip = false;
|
||||
// bool flip = false;
|
||||
bool flipX = false; //TODO: deal with negative scale instead of Flip Key for Spine 3.0
|
||||
bool flipY = false; //TODO: deal with negative scale instead of Flip Key for Spine 3.0
|
||||
Bone parentBone = null;
|
||||
@ -354,22 +361,24 @@ public class SkeletonRagdoll : MonoBehaviour {
|
||||
if (b != startingBone) {
|
||||
parentBone = b.Parent;
|
||||
parentTransform = boneTable[parentBone];
|
||||
flipX = parentBone.WorldFlipX;
|
||||
flipY = parentBone.WorldFlipY;
|
||||
// MITCH
|
||||
// flipX = parentBone.WorldFlipX;
|
||||
// flipY = parentBone.WorldFlipY;
|
||||
|
||||
} else {
|
||||
} else {
|
||||
parentBone = b.Parent;
|
||||
parentTransform = ragdollRoot;
|
||||
if (b.Parent != null) {
|
||||
flipX = b.worldFlipX;
|
||||
flipY = b.WorldFlipY;
|
||||
} else {
|
||||
// MITCH
|
||||
// flipX = b.worldFlipX;
|
||||
// flipY = b.WorldFlipY;
|
||||
} else {
|
||||
flipX = b.Skeleton.FlipX;
|
||||
flipY = b.Skeleton.FlipY;
|
||||
}
|
||||
}
|
||||
|
||||
flip = flipX ^ flipY;
|
||||
//flip = flipX ^ flipY;
|
||||
|
||||
helper.position = parentTransform.position;
|
||||
helper.rotation = parentTransform.rotation;
|
||||
@ -385,26 +394,30 @@ public class SkeletonRagdoll : MonoBehaviour {
|
||||
|
||||
float a = Mathf.Atan2(right.y, right.x) * Mathf.Rad2Deg;
|
||||
|
||||
if (b.WorldFlipX ^ b.WorldFlipY) {
|
||||
a *= -1;
|
||||
}
|
||||
// MITCH
|
||||
//if (b.WorldFlipX ^ b.WorldFlipY) {
|
||||
// a *= -1;
|
||||
//}
|
||||
|
||||
if (parentBone != null) {
|
||||
if ((b.WorldFlipX ^ b.WorldFlipY) != flip) {
|
||||
a -= GetCompensatedRotationIK(parentBone) * 2;
|
||||
}
|
||||
// MITCH
|
||||
//if ((b.WorldFlipX ^ b.WorldFlipY) != flip) {
|
||||
// a -= GetCompensatedRotationIK(parentBone) * 2;
|
||||
//}
|
||||
}
|
||||
|
||||
b.Rotation = Mathf.Lerp(b.Rotation, a, mix);
|
||||
b.RotationIK = Mathf.Lerp(b.rotationIK, a, mix);
|
||||
// MITCH
|
||||
// b.RotationIK = Mathf.Lerp(b.rotationIK, a, mix);
|
||||
}
|
||||
}
|
||||
|
||||
float GetCompensatedRotationIK (Bone b) {
|
||||
Bone parent = b.Parent;
|
||||
float a = b.RotationIK;
|
||||
// MITCH
|
||||
float a = b.AppliedRotation;
|
||||
while (parent != null) {
|
||||
a += parent.RotationIK;
|
||||
a += parent.AppliedRotation;
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
|
||||
@ -261,7 +261,9 @@ public class SkeletonRagdoll2D : MonoBehaviour {
|
||||
|
||||
t.localPosition = new Vector3(b.WorldX, b.WorldY, 0);
|
||||
//TODO: deal with WorldFlipY
|
||||
t.localRotation = Quaternion.Euler(0, 0, b.WorldFlipX ? -b.WorldRotation : b.WorldRotation);
|
||||
// MITCH
|
||||
// t.localRotation = Quaternion.Euler(0, 0, b.WorldFlipX ? -b.WorldRotation : b.WorldRotation);
|
||||
t.localRotation = Quaternion.Euler(0, 0, b.WorldRotationX);
|
||||
t.localScale = new Vector3(b.WorldScaleX, b.WorldScaleY, 0);
|
||||
|
||||
float length = b.Data.Length;
|
||||
@ -281,7 +283,9 @@ public class SkeletonRagdoll2D : MonoBehaviour {
|
||||
var box = go.AddComponent<BoxCollider2D>();
|
||||
box.size = new Vector2(length, thickness);
|
||||
#if UNITY_5
|
||||
box.offset = new Vector2((b.WorldFlipX ? -length : length) / 2, 0);
|
||||
// MITCH
|
||||
// box.offset = new Vector2((b.WorldFlipX ? -length : length) / 2, 0);
|
||||
box.offset = new Vector2(length / 2, 0);
|
||||
#else
|
||||
box.center = new Vector2((b.WorldFlipX ? -length : length) / 2, 0);
|
||||
#endif
|
||||
@ -304,8 +308,11 @@ public class SkeletonRagdoll2D : MonoBehaviour {
|
||||
if (skin == null)
|
||||
skin = skeleton.Data.DefaultSkin;
|
||||
|
||||
bool flipX = b.WorldFlipX;
|
||||
bool flipY = b.WorldFlipY;
|
||||
// MITCH
|
||||
// bool flipX = b.WorldFlipX;
|
||||
// bool flipY = b.WorldFlipY;
|
||||
bool flipX = false;
|
||||
bool flipY = false;
|
||||
|
||||
List<Attachment> attachments = new List<Attachment>();
|
||||
foreach (Slot s in skeleton.Slots) {
|
||||
@ -345,7 +352,7 @@ public class SkeletonRagdoll2D : MonoBehaviour {
|
||||
foreach (var pair in boneTable) {
|
||||
var b = pair.Key;
|
||||
var t = pair.Value;
|
||||
bool flip = false;
|
||||
//bool flip = false;
|
||||
bool flipX = false; //TODO: deal with negative scale instead of Flip Key
|
||||
bool flipY = false; //TODO: deal with negative scale instead of Flip Key
|
||||
Bone parentBone = null;
|
||||
@ -354,22 +361,24 @@ public class SkeletonRagdoll2D : MonoBehaviour {
|
||||
if (b != startingBone) {
|
||||
parentBone = b.Parent;
|
||||
parentTransform = boneTable[parentBone];
|
||||
flipX = parentBone.WorldFlipX;
|
||||
flipY = parentBone.WorldFlipY;
|
||||
// MITCH
|
||||
// flipX = parentBone.WorldFlipX;
|
||||
// flipY = parentBone.WorldFlipY;
|
||||
|
||||
} else {
|
||||
parentBone = b.Parent;
|
||||
parentTransform = ragdollRoot;
|
||||
if (b.Parent != null) {
|
||||
flipX = b.worldFlipX;
|
||||
flipY = b.WorldFlipY;
|
||||
// MITCH
|
||||
// flipX = b.worldFlipX;
|
||||
// flipY = b.WorldFlipY;
|
||||
} else {
|
||||
flipX = b.Skeleton.FlipX;
|
||||
flipY = b.Skeleton.FlipY;
|
||||
}
|
||||
}
|
||||
|
||||
flip = flipX ^ flipY;
|
||||
//flip = flipX ^ flipY;
|
||||
|
||||
helper.position = parentTransform.position;
|
||||
helper.rotation = parentTransform.rotation;
|
||||
@ -385,26 +394,30 @@ public class SkeletonRagdoll2D : MonoBehaviour {
|
||||
|
||||
float a = Mathf.Atan2(right.y, right.x) * Mathf.Rad2Deg;
|
||||
|
||||
if (b.WorldFlipX ^ b.WorldFlipY) {
|
||||
a *= -1;
|
||||
}
|
||||
// MITCH
|
||||
//if (b.WorldFlipX ^ b.WorldFlipY) {
|
||||
// a *= -1;
|
||||
//}
|
||||
|
||||
if (parentBone != null) {
|
||||
if ((b.WorldFlipX ^ b.WorldFlipY) != flip) {
|
||||
a -= GetCompensatedRotationIK(parentBone) * 2;
|
||||
}
|
||||
// MITCH
|
||||
//if ((b.WorldFlipX ^ b.WorldFlipY) != flip) {
|
||||
// a -= GetCompensatedRotationIK(parentBone) * 2;
|
||||
//}
|
||||
}
|
||||
|
||||
b.Rotation = Mathf.Lerp(b.Rotation, a, mix);
|
||||
b.RotationIK = Mathf.Lerp(b.rotationIK, a, mix);
|
||||
// MITCH
|
||||
// b.RotationIK = Mathf.Lerp(b.rotationIK, a, mix);
|
||||
}
|
||||
}
|
||||
|
||||
float GetCompensatedRotationIK (Bone b) {
|
||||
Bone parent = b.Parent;
|
||||
float a = b.RotationIK;
|
||||
// MITCH
|
||||
float a = b.AppliedRotation;
|
||||
while (parent != null) {
|
||||
a += parent.RotationIK;
|
||||
a += parent.AppliedRotation;
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ public static class SkeletonExtensions {
|
||||
public static Color GetColor (this Skeleton s) { return new Color(s.r, s.g, s.b, s.a); }
|
||||
public static Color GetColor (this RegionAttachment a) { return new Color(a.r, a.g, a.b, a.a); }
|
||||
public static Color GetColor (this MeshAttachment a) { return new Color(a.r, a.g, a.b, a.a); }
|
||||
public static Color GetColor (this SkinnedMeshAttachment a) { return new Color(a.r, a.g, a.b, a.a); }
|
||||
public static Color GetColor (this WeightedMeshAttachment a) { return new Color(a.r, a.g, a.b, a.a); }
|
||||
|
||||
public static void SetColor (this Skeleton skeleton, Color color) {
|
||||
skeleton.A = color.a;
|
||||
@ -75,14 +75,14 @@ public static class SkeletonExtensions {
|
||||
attachment.B = color.b * ByteToFloat;
|
||||
}
|
||||
|
||||
public static void SetColor (this SkinnedMeshAttachment attachment, Color color) {
|
||||
public static void SetColor (this WeightedMeshAttachment attachment, Color color) {
|
||||
attachment.A = color.a;
|
||||
attachment.R = color.r;
|
||||
attachment.G = color.g;
|
||||
attachment.B = color.b;
|
||||
}
|
||||
|
||||
public static void SetColor (this SkinnedMeshAttachment attachment, Color32 color) {
|
||||
public static void SetColor (this WeightedMeshAttachment attachment, Color32 color) {
|
||||
attachment.A = color.a * ByteToFloat;
|
||||
attachment.R = color.r * ByteToFloat;
|
||||
attachment.G = color.g * ByteToFloat;
|
||||
|
||||
@ -250,8 +250,9 @@ public class SkeletonRenderer : MonoBehaviour {
|
||||
int attachmentVertexCount, attachmentTriangleCount;
|
||||
|
||||
// Handle flipping for normals (for lighting).
|
||||
bool worldScaleIsSameSigns = ((bone.worldScaleY >= 0f) == (bone.worldScaleX >= 0f));
|
||||
bool flip = frontFacing && ((bone.worldFlipX != bone.worldFlipY) == worldScaleIsSameSigns); // TODO: bone flipX and flipY will be removed in Spine 3.0
|
||||
// MITCH
|
||||
bool worldScaleIsSameSigns = ((bone.WorldSignX >= 0f) == (bone.WorldSignY >= 0f));
|
||||
bool flip = frontFacing && ((bone.WorldSignX != bone.WorldSignY) == worldScaleIsSameSigns); // TODO: bone flipX and flipY will be removed in Spine 3.0
|
||||
|
||||
workingFlipsItems[i] = flip;
|
||||
workingAttachmentsItems[i] = attachment;
|
||||
@ -274,7 +275,7 @@ public class SkeletonRenderer : MonoBehaviour {
|
||||
attachmentVertexCount = meshAttachment.vertices.Length >> 1;
|
||||
attachmentTriangleCount = meshAttachment.triangles.Length;
|
||||
} else {
|
||||
var skinnedMeshAttachment = attachment as SkinnedMeshAttachment;
|
||||
var skinnedMeshAttachment = attachment as WeightedMeshAttachment;
|
||||
if (skinnedMeshAttachment != null) {
|
||||
rendererObject = skinnedMeshAttachment.RendererObject;
|
||||
attachmentVertexCount = skinnedMeshAttachment.uvs.Length >> 1;
|
||||
@ -531,20 +532,20 @@ public class SkeletonRenderer : MonoBehaviour {
|
||||
meshBoundsMax.y = y;
|
||||
}
|
||||
} else {
|
||||
SkinnedMeshAttachment skinnedMeshAttachment = attachment as SkinnedMeshAttachment;
|
||||
if (skinnedMeshAttachment != null) {
|
||||
int meshVertexCount = skinnedMeshAttachment.uvs.Length;
|
||||
WeightedMeshAttachment weightedMeshAttachment = attachment as WeightedMeshAttachment;
|
||||
if (weightedMeshAttachment != null) {
|
||||
int meshVertexCount = weightedMeshAttachment.uvs.Length;
|
||||
if (tempVertices.Length < meshVertexCount)
|
||||
this.tempVertices = tempVertices = new float[meshVertexCount];
|
||||
skinnedMeshAttachment.ComputeWorldVertices(slot, tempVertices);
|
||||
weightedMeshAttachment.ComputeWorldVertices(slot, tempVertices);
|
||||
|
||||
color.a = (byte)(a * slot.a * skinnedMeshAttachment.a);
|
||||
color.r = (byte)(r * slot.r * skinnedMeshAttachment.r * color.a);
|
||||
color.g = (byte)(g * slot.g * skinnedMeshAttachment.g * color.a);
|
||||
color.b = (byte)(b * slot.b * skinnedMeshAttachment.b * color.a);
|
||||
color.a = (byte)(a * slot.a * weightedMeshAttachment.a);
|
||||
color.r = (byte)(r * slot.r * weightedMeshAttachment.r * color.a);
|
||||
color.g = (byte)(g * slot.g * weightedMeshAttachment.g * color.a);
|
||||
color.b = (byte)(b * slot.b * weightedMeshAttachment.b * color.a);
|
||||
if (slot.data.blendMode == BlendMode.additive) color.a = 0;
|
||||
|
||||
float[] meshUVs = skinnedMeshAttachment.uvs;
|
||||
float[] meshUVs = weightedMeshAttachment.uvs;
|
||||
float z = i * zSpacing;
|
||||
for (int ii = 0; ii < meshVertexCount; ii += 2, vertexIndex++) {
|
||||
float x = tempVertices[ii], y = tempVertices[ii + 1];
|
||||
@ -756,10 +757,10 @@ public class SkeletonRenderer : MonoBehaviour {
|
||||
attachmentVertexCount = meshAttachment.vertices.Length >> 1; // length/2
|
||||
attachmentTriangles = meshAttachment.triangles;
|
||||
} else {
|
||||
var skinnedMeshAttachment = attachment as SkinnedMeshAttachment;
|
||||
if (skinnedMeshAttachment != null) {
|
||||
attachmentVertexCount = skinnedMeshAttachment.uvs.Length >> 1; // length/2
|
||||
attachmentTriangles = skinnedMeshAttachment.triangles;
|
||||
var weightedMeshAttachment = attachment as WeightedMeshAttachment;
|
||||
if (weightedMeshAttachment != null) {
|
||||
attachmentVertexCount = weightedMeshAttachment.uvs.Length >> 1; // length/2
|
||||
attachmentTriangles = weightedMeshAttachment.triangles;
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
@ -774,7 +775,7 @@ public class SkeletonRenderer : MonoBehaviour {
|
||||
for (int ii = 0, nn = attachmentTriangles.Length; ii < nn; ii++, triangleIndex++) {
|
||||
triangles[triangleIndex] = firstVertex + attachmentTriangles[ii];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
firstVertex += attachmentVertexCount;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public class SkeletonUtilityInspector : Editor {
|
||||
foreach (Bone b in skeleton.Bones) {
|
||||
Vector3 vec = transform.TransformPoint(new Vector3(b.WorldX, b.WorldY, 0));
|
||||
|
||||
Quaternion rot = Quaternion.Euler(0, 0, b.WorldRotation * flipRotation);
|
||||
Quaternion rot = Quaternion.Euler(0, 0, b.WorldRotationX * flipRotation);
|
||||
Vector3 forward = transform.TransformDirection(rot * Vector3.right);
|
||||
forward *= flipRotation;
|
||||
|
||||
@ -221,7 +221,7 @@ public class SkeletonUtilityInspector : Editor {
|
||||
|
||||
Texture2D icon = null;
|
||||
|
||||
if (attachment is MeshAttachment || attachment is SkinnedMeshAttachment)
|
||||
if (attachment is MeshAttachment || attachment is WeightedMeshAttachment)
|
||||
icon = SpineEditorUtilities.Icons.mesh;
|
||||
else
|
||||
icon = SpineEditorUtilities.Icons.image;
|
||||
|
||||
@ -370,7 +370,7 @@ public class SkeletonUtility : MonoBehaviour {
|
||||
|
||||
if (mode == SkeletonUtilityBone.Mode.Override) {
|
||||
if (rot)
|
||||
go.transform.localRotation = Quaternion.Euler(0, 0, b.bone.RotationIK);
|
||||
go.transform.localRotation = Quaternion.Euler(0, 0, b.bone.AppliedRotation);
|
||||
|
||||
if (pos)
|
||||
go.transform.localPosition = new Vector3(b.bone.X, b.bone.Y, 0);
|
||||
|
||||
@ -114,13 +114,16 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
||||
float skeletonFlipRotation = (skeleton.flipX ^ skeleton.flipY) ? -1f : 1f;
|
||||
|
||||
float flipCompensation = 0;
|
||||
if (flip && (flipX || (flipX != bone.flipX)) && bone.parent != null) {
|
||||
flipCompensation = bone.parent.WorldRotation * -2;
|
||||
}
|
||||
|
||||
// MITCH
|
||||
//if (flip && (flipX || (flipX != bone.flipX)) && bone.parent != null) {
|
||||
// flipCompensation = bone.parent.WorldRotation * -2;
|
||||
//}
|
||||
|
||||
if (mode == Mode.Follow) {
|
||||
if (flip) {
|
||||
flipX = bone.flipX;
|
||||
// MITCH
|
||||
//flipX = bone.flipX;
|
||||
}
|
||||
|
||||
|
||||
@ -131,20 +134,21 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
||||
if (rotation) {
|
||||
|
||||
if (bone.Data.InheritRotation) {
|
||||
if (bone.FlipX) {
|
||||
cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation);
|
||||
} else {
|
||||
cachedTransform.localRotation = Quaternion.Euler(0, 0, bone.rotationIK);
|
||||
}
|
||||
// MITCH
|
||||
//if (bone.FlipX) {
|
||||
// cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation);
|
||||
//} else {
|
||||
cachedTransform.localRotation = Quaternion.Euler(0, 0, bone.AppliedRotation);
|
||||
//}
|
||||
} else {
|
||||
Vector3 euler = skeletonTransform.rotation.eulerAngles;
|
||||
cachedTransform.rotation = Quaternion.Euler(euler.x, euler.y, skeletonTransform.rotation.eulerAngles.z + (bone.worldRotation * skeletonFlipRotation));
|
||||
cachedTransform.rotation = Quaternion.Euler(euler.x, euler.y, skeletonTransform.rotation.eulerAngles.z + (bone.WorldRotationX * skeletonFlipRotation));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (scale) {
|
||||
cachedTransform.localScale = new Vector3(bone.scaleX, bone.scaleY, bone.worldFlipX ? -1 : 1);
|
||||
cachedTransform.localScale = new Vector3(bone.scaleX, bone.scaleY, bone.WorldSignX);
|
||||
|
||||
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
|
||||
}
|
||||
@ -166,9 +170,10 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
||||
float angle = Mathf.LerpAngle(bone.Rotation, cachedTransform.localRotation.eulerAngles.z, overrideAlpha) + flipCompensation;
|
||||
|
||||
if (flip) {
|
||||
if ((!flipX && bone.flipX)) {
|
||||
angle -= flipCompensation;
|
||||
}
|
||||
// MITCH
|
||||
//if ((!flipX && bone.flipX)) {
|
||||
// angle -= flipCompensation;
|
||||
//}
|
||||
|
||||
//TODO fix this...
|
||||
if (angle >= 360)
|
||||
@ -178,7 +183,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
||||
}
|
||||
|
||||
bone.Rotation = angle;
|
||||
bone.RotationIK = angle;
|
||||
bone.AppliedRotation = angle;
|
||||
}
|
||||
|
||||
if (scale) {
|
||||
@ -188,9 +193,10 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
||||
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
|
||||
}
|
||||
|
||||
if (flip) {
|
||||
bone.flipX = flipX;
|
||||
}
|
||||
// MITCH
|
||||
//if (flip) {
|
||||
// bone.flipX = flipX;
|
||||
//}
|
||||
} else {
|
||||
|
||||
if (transformLerpComplete)
|
||||
@ -206,9 +212,10 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
||||
float angle = Mathf.LerpAngle(bone.Rotation, Quaternion.LookRotation(flipX ? Vector3.forward * -1 : Vector3.forward, parentReference.InverseTransformDirection(cachedTransform.up)).eulerAngles.z, overrideAlpha) + flipCompensation;
|
||||
|
||||
if (flip) {
|
||||
if ((!flipX && bone.flipX)) {
|
||||
angle -= flipCompensation;
|
||||
}
|
||||
// MITCH
|
||||
//if ((!flipX && bone.flipX)) {
|
||||
// angle -= flipCompensation;
|
||||
//}
|
||||
|
||||
//TODO fix this...
|
||||
if (angle >= 360)
|
||||
@ -218,7 +225,7 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
||||
}
|
||||
|
||||
bone.Rotation = angle;
|
||||
bone.RotationIK = angle;
|
||||
bone.AppliedRotation = angle;
|
||||
}
|
||||
|
||||
//TODO: Something about this
|
||||
@ -229,10 +236,10 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
||||
nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
|
||||
}
|
||||
|
||||
if (flip) {
|
||||
bone.flipX = flipX;
|
||||
}
|
||||
|
||||
// MITCH
|
||||
//if (flip) {
|
||||
// bone.flipX = flipX;
|
||||
//}
|
||||
}
|
||||
|
||||
transformLerpComplete = true;
|
||||
@ -251,11 +258,14 @@ public class SkeletonUtilityBone : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
bone.FlipX = state;
|
||||
// MITCH
|
||||
//bone.FlipX = state;
|
||||
transform.RotateAround(transform.position, skeletonUtility.transform.up, 180);
|
||||
Vector3 euler = transform.localRotation.eulerAngles;
|
||||
euler.x = 0;
|
||||
euler.y = bone.FlipX ? 180 : 0;
|
||||
// MITCH
|
||||
//euler.y = bone.FlipX ? 180 : 0;
|
||||
euler.y = 0;
|
||||
transform.localRotation = Quaternion.Euler(euler);
|
||||
}
|
||||
|
||||
|
||||
@ -189,7 +189,7 @@ public class SpriteAttachmentLoader : AttachmentLoader {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public SkinnedMeshAttachment NewSkinnedMeshAttachment (Skin skin, string name, string path) {
|
||||
public WeightedMeshAttachment NewWeightedMeshAttachment(Skin skin, string name, string path) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
9
spine-unity/Assets/spine-unity/YieldInstructions.meta
Normal file
9
spine-unity/Assets/spine-unity/YieldInstructions.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15ac4befbee15d845ac289de3ab6d3d4
|
||||
folderAsset: yes
|
||||
timeCreated: 1455486167
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user