diff --git a/spine-csharp/src/SkeletonJson.cs b/spine-csharp/src/SkeletonJson.cs index 948834850..3cfbdc76f 100644 --- a/spine-csharp/src/SkeletonJson.cs +++ b/spine-csharp/src/SkeletonJson.cs @@ -28,7 +28,7 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#if (UNITY_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_WSA || UNITY_WP8 || UNITY_WP8_1) +#if (UNITY_5 || UNITY_5_3_OR_NEWER || UNITY_WSA || UNITY_WP8 || UNITY_WP8_1) #define IS_UNITY #endif diff --git a/spine-unity/Assets/Examples/Getting Started/2 Controlling Animation.unity b/spine-unity/Assets/Examples/Getting Started/2 Controlling Animation.unity index 7758c884b..5286c9703 100644 --- a/spine-unity/Assets/Examples/Getting Started/2 Controlling Animation.unity +++ b/spine-unity/Assets/Examples/Getting Started/2 Controlling Animation.unity @@ -405,6 +405,7 @@ MonoBehaviour: shootAnimationName: shoot idleTurnAnimationName: idle-turn runToIdleAnimationName: run-to-idle + runWalkDuration: 1.5 --- !u!1 &926099111 GameObject: m_ObjectHideFlags: 0 diff --git a/spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs b/spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs index b6620db7d..0de31c2f8 100644 --- a/spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs +++ b/spine-unity/Assets/Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs @@ -55,6 +55,8 @@ namespace Spine.Unity.Examples { [SpineAnimation] public string runToIdleAnimationName; + + public float runWalkDuration = 1.5f; #endregion SkeletonAnimation skeletonAnimation; @@ -81,10 +83,10 @@ namespace Spine.Unity.Examples { // Common Mistake: If you keep calling it in Update, it will keep showing the first pose of the animation, do don't do that. spineAnimationState.SetAnimation(0, walkAnimationName, true); - yield return new WaitForSeconds(1.5f); + yield return new WaitForSeconds(runWalkDuration); spineAnimationState.SetAnimation(0, runAnimationName, true); - yield return new WaitForSeconds(1.5f); + yield return new WaitForSeconds(runWalkDuration); // AddAnimation queues up an animation to play after the previous one ends. spineAnimationState.SetAnimation(0, runToIdleAnimationName, false); diff --git a/spine-unity/Assets/Examples/Scripts/MixAndMatch.cs b/spine-unity/Assets/Examples/Scripts/MixAndMatch.cs index 3bc403c42..5c161dc3d 100644 --- a/spine-unity/Assets/Examples/Scripts/MixAndMatch.cs +++ b/spine-unity/Assets/Examples/Scripts/MixAndMatch.cs @@ -87,7 +87,7 @@ namespace Spine.Unity.Examples { // STEP 1: "EQUIP" ITEMS USING SPRITES // STEP 1.1 Find the original attachment. // Step 1.2 Get a clone of the original attachment. - // Step 1.3 Apply the Sprite image to it. + // Step 1.3 Apply the Sprite image to the clone. // Step 1.4 Add the remapped clone to the new custom skin. // Let's do this for the visor. diff --git a/spine-unity/Assets/Examples/Spine/spineboy-pro/spineboy_SkeletonData.asset b/spine-unity/Assets/Examples/Spine/spineboy-pro/spineboy_SkeletonData.asset index 510a567c3..62ac89491 100644 --- a/spine-unity/Assets/Examples/Spine/spineboy-pro/spineboy_SkeletonData.asset +++ b/spine-unity/Assets/Examples/Spine/spineboy-pro/spineboy_SkeletonData.asset @@ -27,7 +27,7 @@ MonoBehaviour: - walk duration: - 0 - - 0.05 + - 0.1 - 0.3 - 0.3 defaultMix: 0.1 diff --git a/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.atlas b/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.atlas new file mode 100644 index 000000000..d53685677 --- /dev/null +++ b/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.atlas @@ -0,0 +1,195 @@ + +spineboy-unity.png +size: 2048,512 +format: RGBA8888 +filter: Linear,Linear +repeat: none +eye_indifferent + rotate: false + xy: 652, 113 + size: 93, 89 + orig: 93, 89 + offset: 0, 0 + index: -1 +eye_surprised + rotate: false + xy: 747, 118 + size: 93, 89 + orig: 93, 89 + offset: 0, 0 + index: -1 +front_bracer + rotate: true + xy: 919, 276 + size: 58, 80 + orig: 58, 80 + offset: 0, 0 + index: -1 +front_fist_closed + rotate: false + xy: 1762, 420 + size: 75, 82 + orig: 75, 82 + offset: 0, 0 + index: -1 +front_fist_open + rotate: true + xy: 1673, 416 + size: 86, 87 + orig: 86, 87 + offset: 0, 0 + index: -1 +front_foot + rotate: false + xy: 1324, 433 + size: 126, 69 + orig: 126, 69 + offset: 0, 0 + index: -1 +front_foot_bend1 + rotate: false + xy: 184, 30 + size: 128, 70 + orig: 128, 70 + offset: 0, 0 + index: -1 +front_foot_bend2 + rotate: false + xy: 1214, 409 + size: 108, 93 + orig: 108, 93 + offset: 0, 0 + index: -1 +front_shin + rotate: true + xy: 466, 120 + size: 82, 184 + orig: 82, 184 + offset: 0, 0 + index: -1 +front_thigh + rotate: true + xy: 739, 209 + size: 48, 112 + orig: 48, 112 + offset: 0, 0 + index: -1 +front_upper_arm + rotate: true + xy: 1214, 268 + size: 54, 97 + orig: 54, 97 + offset: 0, 0 + index: -1 +goggles + rotate: false + xy: 739, 336 + size: 261, 166 + orig: 261, 166 + offset: 0, 0 + index: -1 +gun + rotate: false + xy: 1002, 299 + size: 210, 203 + orig: 210, 203 + offset: 0, 0 + index: -1 +head + rotate: false + xy: 466, 204 + size: 271, 298 + orig: 271, 298 + offset: 0, 0 + index: -1 +mouth_grind + rotate: false + xy: 1839, 443 + size: 93, 59 + orig: 93, 59 + offset: 0, 0 + index: -1 +mouth_oooo + rotate: false + xy: 1934, 443 + size: 93, 59 + orig: 93, 59 + offset: 0, 0 + index: -1 +mouth_smile + rotate: false + xy: 1324, 372 + size: 93, 59 + orig: 93, 59 + offset: 0, 0 + index: -1 +muzzle + rotate: false + xy: 2, 102 + size: 462, 400 + orig: 462, 400 + offset: 0, 0 + index: -1 +neck + rotate: false + xy: 853, 216 + size: 36, 41 + orig: 36, 41 + offset: 0, 0 + index: -1 +rear_bracer + rotate: true + xy: 1313, 265 + size: 56, 72 + orig: 56, 72 + offset: 0, 0 + index: -1 +rear_foot + rotate: false + xy: 1452, 442 + size: 113, 60 + orig: 113, 60 + offset: 0, 0 + index: -1 +rear_foot_bend1 + rotate: false + xy: 314, 34 + size: 117, 66 + orig: 117, 66 + offset: 0, 0 + index: -1 +rear_foot_bend2 + rotate: false + xy: 1214, 324 + size: 103, 83 + orig: 103, 83 + offset: 0, 0 + index: -1 +rear_shin + rotate: true + xy: 739, 259 + size: 75, 178 + orig: 75, 178 + offset: 0, 0 + index: -1 +rear_thigh + rotate: true + xy: 1567, 437 + size: 65, 104 + orig: 65, 104 + offset: 0, 0 + index: -1 +rear_upper_arm + rotate: true + xy: 1319, 323 + size: 47, 87 + orig: 47, 87 + offset: 0, 0 + index: -1 +torso + rotate: true + xy: 2, 2 + size: 98, 180 + orig: 98, 180 + offset: 0, 0 + index: -1 diff --git a/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.atlas.meta b/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.atlas.meta new file mode 100644 index 000000000..4e962cbe6 --- /dev/null +++ b/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.atlas.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c3184a6ff8f29e8429a443fd3d80a069 +timeCreated: 1497568842 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.png b/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.png new file mode 100644 index 000000000..aafaddfb2 Binary files /dev/null and b/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.png differ diff --git a/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.png.meta b/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.png.meta new file mode 100644 index 000000000..9e016df3b --- /dev/null +++ b/spine-unity/Assets/Examples/Spine/spineboy-unity/spineboy-unity.png.meta @@ -0,0 +1,68 @@ +fileFormatVersion: 2 +guid: 2f762ed708bf8634481116a5e53c52f2 +timeCreated: 1497568842 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs b/spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs index 71f5fe406..699c7aef5 100644 --- a/spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs +++ b/spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs @@ -134,9 +134,6 @@ namespace Spine.Unity.Editor { //generate new dummy clip AnimationClip newClip = new AnimationClip(); newClip.name = name; - #if !(UNITY_5) - AnimationUtility.SetAnimationType(newClip, ModelImporterAnimationType.Generic); - #endif AssetDatabase.AddObjectToAsset(newClip, controller); unityAnimationClipTable.Add(name, newClip); } diff --git a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs index db3416204..68e7780f2 100644 --- a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs +++ b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs @@ -36,6 +36,9 @@ using System.Collections.Generic; namespace Spine.Unity { [RequireComponent(typeof(Animator))] public class SkeletonAnimator : SkeletonRenderer, ISkeletonAnimation { + + [SerializeField] protected MecanimTranslator translator; + public MecanimTranslator Translator { get { return translator; } } #region Bone Callbacks (ISkeletonAnimation) protected event UpdateBonesDelegate _UpdateLocal; @@ -60,9 +63,35 @@ namespace Spine.Unity { public event UpdateBonesDelegate UpdateComplete { add { _UpdateComplete += value; } remove { _UpdateComplete -= value; } } #endregion - public bool AutoReset { - get { return mecanimTranslator.autoReset; } - set { mecanimTranslator.autoReset = value; } + public override void Initialize (bool overwrite) { + if (valid && !overwrite) return; + base.Initialize(overwrite); + if (!valid) return; + + if (translator == null) translator = new MecanimTranslator(); + translator.Initialize(GetComponent(), this.skeletonDataAsset); + } + + public void Update () { + if (!valid) return; + + translator.Apply(skeleton); + + // UpdateWorldTransform and Bone Callbacks + { + if (_UpdateLocal != null) + _UpdateLocal(this); + + skeleton.UpdateWorldTransform(); + + if (_UpdateWorld != null) { + _UpdateWorld(this); + skeleton.UpdateWorldTransform(); + } + + if (_UpdateComplete != null) + _UpdateComplete(this); + } } [System.Serializable] @@ -79,6 +108,8 @@ namespace Spine.Unity { readonly List previousAnimations = new List(); Animator animator; + public Animator Animator { get { return this.animator; } } + public void Initialize (Animator animator, SkeletonDataAsset skeletonDataAsset) { this.animator = animator; animationTable.Clear(); @@ -92,7 +123,7 @@ namespace Spine.Unity { if (layerMixModes.Length < animator.layerCount) System.Array.Resize(ref layerMixModes, animator.layerCount); - + //skeleton.Update(Time.deltaTime); // Doesn't actually do anything, currently. (Spine 3.6). // Clear Previous @@ -214,37 +245,5 @@ namespace Spine.Unity { } } - public MecanimTranslator mecanimTranslator; - - public override void Initialize (bool overwrite) { - if (valid && !overwrite) return; - base.Initialize(overwrite); - if (!valid) return; - - mecanimTranslator = mecanimTranslator ?? new MecanimTranslator(); - mecanimTranslator.Initialize(GetComponent(), this.skeletonDataAsset); - } - - public void Update () { - if (!valid) return; - - mecanimTranslator.Apply(skeleton); - - // UpdateWorldTransform and Bone Callbacks - { - if (_UpdateLocal != null) - _UpdateLocal(this); - - skeleton.UpdateWorldTransform(); - - if (_UpdateWorld != null) { - _UpdateWorld(this); - skeleton.UpdateWorldTransform(); - } - - if (_UpdateComplete != null) - _UpdateComplete(this); - } - } } }