From 13f433d13d9d60ed7b8070a7358f58acb978982a Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 29 Aug 2016 17:10:52 +0800 Subject: [PATCH 1/3] [unity] Fix compatibility with Unity 5.1. --- spine-unity/Assets/Examples/Scripts/SpineboyPole.cs | 2 +- .../Assets/spine-unity/Editor/SpineEditorUtilities.cs | 6 +++++- .../Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spine-unity/Assets/Examples/Scripts/SpineboyPole.cs b/spine-unity/Assets/Examples/Scripts/SpineboyPole.cs index 9c4e8507c..319c6cb0b 100644 --- a/spine-unity/Assets/Examples/Scripts/SpineboyPole.cs +++ b/spine-unity/Assets/Examples/Scripts/SpineboyPole.cs @@ -8,7 +8,7 @@ public class SpineboyPole : MonoBehaviour { public SkeletonAnimation skeletonAnimation; public SkeletonRenderSeparator separator; - [Space] + [Space(18)] [SpineAnimation] public string run; [SpineAnimation] diff --git a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs index fec3e770a..a065608d7 100644 --- a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs +++ b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs @@ -260,7 +260,11 @@ namespace Spine.Unity.Editor { EditorPrefs.SetFloat(DEFAULT_SCALE_KEY, defaultScale); EditorGUI.BeginChangeCheck(); - defaultShader = EditorGUILayout.DelayedTextField(new GUIContent("Default shader", "Default shader for materials auto-generated on import."), defaultShader); + #if UNITY_5_3_OR_NEWER + defaultShader = EditorGUILayout.DelayedTextField(new GUIContent("Default shader", "Default shader for materials auto-generated on import."), defaultShader); + #else + defaultShader = EditorGUILayout.TextField(new GUIContent("Default shader", "Default shader for materials auto-generated on import."), defaultShader); + #endif if (EditorGUI.EndChangeCheck()) EditorPrefs.SetString(DEFAULT_SHADER_KEY, defaultShader); diff --git a/spine-unity/Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll.cs b/spine-unity/Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll.cs index 5fdf93743..ffd57ae0e 100644 --- a/spine-unity/Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll.cs +++ b/spine-unity/Assets/spine-unity/Modules/Ragdoll/SkeletonRagdoll.cs @@ -24,7 +24,7 @@ namespace Spine.Unity.Modules { [Tooltip("Warning! You will have to re-enable and tune mix values manually if attempting to remove the ragdoll system.")] public bool disableIK = true; public bool disableOtherConstraints = false; - [Space] + [Space(18)] [Tooltip("Set RootRigidbody IsKinematic to true when Apply is called.")] public bool pinStartBone; [Tooltip("Enable Collision between adjacent ragdoll elements (IE: Neck and Head)")] From ee324f4bde7ffdf9f927fc665b7b0c9957aa1c86 Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 29 Aug 2016 17:17:28 +0800 Subject: [PATCH 2/3] [unity] Make SkeletonDataAsset safer to create at runtime. --- .../Assets/spine-unity/Asset Types/SkeletonDataAsset.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spine-unity/Assets/spine-unity/Asset Types/SkeletonDataAsset.cs b/spine-unity/Assets/spine-unity/Asset Types/SkeletonDataAsset.cs index da8629261..2a06f8bd5 100644 --- a/spine-unity/Assets/spine-unity/Asset Types/SkeletonDataAsset.cs +++ b/spine-unity/Assets/spine-unity/Asset Types/SkeletonDataAsset.cs @@ -161,6 +161,11 @@ namespace Spine.Unity { return; stateData.DefaultMix = defaultMix; + + // For compatibility with runtime-instantiated SkeletonDataAsset. + if (fromAnimation == null || toAnimation == null) + return; + for (int i = 0, n = fromAnimation.Length; i < n; i++) { if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue; From e0ee7ce4f5dac864bf5556a0146681fbf673f6b5 Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 29 Aug 2016 17:17:56 +0800 Subject: [PATCH 3/3] [unity] Some cleanup and documentation. --- .../spine-unity/Editor/BoneFollowerInspector.cs | 2 +- .../Assets/spine-unity/SkeletonAnimation.cs | 14 ++++++++++++++ spine-unity/Assets/spine-unity/SkeletonAnimator.cs | 14 ++++++++++++++ .../Editor/SkeletonUtilityInspector.cs | 13 ++++--------- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs b/spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs index 534d0510f..e4e367217 100644 --- a/spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs +++ b/spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs @@ -64,8 +64,8 @@ namespace Spine.Unity.Editor { if (skeletonRenderer.objectReferenceValue == null) { SkeletonRenderer parentRenderer = BoneFollowerInspector.GetInParent(targetBoneFollower.transform); if (parentRenderer != null && parentRenderer.gameObject != targetBoneFollower.gameObject) { - Debug.Log("Inspector automatically assigned BoneFollower.SkeletonRenderer"); skeletonRenderer.objectReferenceValue = parentRenderer; + Debug.Log("Inspector automatically assigned BoneFollower.SkeletonRenderer"); } } diff --git a/spine-unity/Assets/spine-unity/SkeletonAnimation.cs b/spine-unity/Assets/spine-unity/SkeletonAnimation.cs index 7fdf243b2..623b3c106 100644 --- a/spine-unity/Assets/spine-unity/SkeletonAnimation.cs +++ b/spine-unity/Assets/spine-unity/SkeletonAnimation.cs @@ -45,16 +45,30 @@ namespace Spine.Unity { public Spine.AnimationState state; public Spine.AnimationState AnimationState { get { return this.state; } } + /// + /// Occurs after the animations are applied and before world space values are resolved. + /// Use this callback when you want to set bone local values. + /// public event UpdateBonesDelegate UpdateLocal { add { _UpdateLocal += value; } remove { _UpdateLocal -= value; } } + /// + /// Occurs after the Skeleton's bone world space values are resolved (including all constraints). + /// Using this callback will cause the world space values to be solved an extra time. + /// Use this callback if want to use bone world space values, and also set bone local values. + /// public event UpdateBonesDelegate UpdateWorld { add { _UpdateWorld += value; } remove { _UpdateWorld -= value; } } + /// + /// Occurs after the Skeleton's bone world space values are resolved (including all constraints). + /// Use this callback if you want to use bone world space values, but don't intend to modify bone local values. + /// This callback can also be used when setting world position and the bone matrix. + /// public event UpdateBonesDelegate UpdateComplete { add { _UpdateComplete += value; } remove { _UpdateComplete -= value; } diff --git a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs index d84482081..b1dbad6d6 100644 --- a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs +++ b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs @@ -14,16 +14,30 @@ namespace Spine.Unity { public enum MixMode { AlwaysMix, MixNext, SpineStyle } public MixMode[] layerMixModes = new MixMode[0]; + /// + /// Occurs after the animations are applied and before world space values are resolved. + /// Use this callback when you want to set bone local values. + /// public event UpdateBonesDelegate UpdateLocal { add { _UpdateLocal += value; } remove { _UpdateLocal -= value; } } + /// + /// Occurs after the Skeleton's bone world space values are resolved (including all constraints). + /// Using this callback will cause the world space values to be solved an extra time. + /// Use this callback if want to use bone world space values, and also set bone local values. + /// public event UpdateBonesDelegate UpdateWorld { add { _UpdateWorld += value; } remove { _UpdateWorld -= value; } } + /// + /// Occurs after the Skeleton's bone world space values are resolved (including all constraints). + /// Use this callback if you want to use bone world space values, but don't intend to modify bone local values. + /// This callback can also be used when setting world position and the bone matrix. + /// public event UpdateBonesDelegate UpdateComplete { add { _UpdateComplete += value; } remove { _UpdateComplete -= value; } diff --git a/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilityInspector.cs b/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilityInspector.cs index 3506fb2b3..385077961 100644 --- a/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilityInspector.cs +++ b/spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilityInspector.cs @@ -12,7 +12,6 @@ using UnityEditor; #else using UnityEditor.AnimatedValues; #endif -using System.Collections; using System.Collections.Generic; using Spine; @@ -111,12 +110,8 @@ namespace Spine.Unity.Editor { void UpdateAttachments () { attachmentTable = new Dictionary>(); - Skin skin = skeleton.Skin; - - if (skin == null) { - skin = skeletonRenderer.skeletonDataAsset.GetSkeletonData(true).DefaultSkin; - } + Skin skin = skeleton.Skin ?? skeletonRenderer.skeletonDataAsset.GetSkeletonData(true).DefaultSkin; for (int i = skeleton.Slots.Count-1; i >= 0; i--) { List attachments = new List(); skin.FindAttachmentsForSlot(i, attachments); @@ -229,14 +224,14 @@ namespace Spine.Unity.Editor { GUI.contentColor = Color.white; } } - #if UNITY_4_3 + #if UNITY_4_3 - #else + #else } EditorGUILayout.EndFadeGroup(); if (showSlots.isAnimating) Repaint(); - #endif + #endif } void SpawnHierarchyContextMenu () {