From 30b36b642369b1f2f471f612798a843f2229cab8 Mon Sep 17 00:00:00 2001 From: Matt Vroman Date: Tue, 1 Mar 2016 11:48:18 -0800 Subject: [PATCH 1/2] Fix Unity 4 compile errors Added preprocessors to allow Spine to compile in Unity 4 --- .../Assets/spine-unity/Mesh Generation/SpineMesh.cs | 5 ++++- spine-unity/Assets/spine-unity/SkeletonAnimator.cs | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs b/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs index 5c532744d..d5c5fe287 100644 --- a/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs +++ b/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs @@ -2,8 +2,11 @@ namespace Spine.Unity { public static class SpineMesh { +#if UNITY_5 internal const HideFlags MeshHideflags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor; - +#else + internal const HideFlags MeshHideflags = HideFlags.DontSave; +#endif /// Factory method for creating a new mesh for use in Spine components. This can be called in field initializers. public static Mesh NewMesh () { var m = new Mesh(); diff --git a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs index c41c0c46a..9cab006f6 100644 --- a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs +++ b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs @@ -111,8 +111,11 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation { float time = stateInfo.normalizedTime * info.clip.length; animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, stateInfo.loop, null, weight); } - +#if UNITY_5 if (nextStateInfo.fullPathHash != 0) { +#else + if (nextStateInfo.nameHash != 0) { +#endif for (int c = 0; c < nextClipInfo.Length; c++) { var info = nextClipInfo[c]; float weight = info.weight * layerWeight; @@ -150,8 +153,11 @@ public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation { } c = 0; - +#if UNITY_5 if (nextStateInfo.fullPathHash != 0) { +#else + if (nextStateInfo.nameHash != 0) { +#endif //apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights) if (mode == MixMode.SpineStyle) { for (; c < nextClipInfo.Length; c++) { From 97cb68749e119d20bf4109440642b45ee135cb5e Mon Sep 17 00:00:00 2001 From: Matt Vroman Date: Tue, 1 Mar 2016 11:57:47 -0800 Subject: [PATCH 2/2] Fix compile error with Bone::WorldFlipX Code previously did not handle flip values, so revert the code to this state for Unity 4 --- .../Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll2D.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spine-unity/Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll2D.cs b/spine-unity/Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll2D.cs index cef143f89..b0dca43b0 100644 --- a/spine-unity/Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll2D.cs +++ b/spine-unity/Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll2D.cs @@ -287,7 +287,8 @@ public class SkeletonRagdoll2D : MonoBehaviour { // 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); + //box.center = new Vector2((b.WorldFlipX ? -length : length) / 2, 0); + box.center = new Vector2(length/2, 0); #endif } }