From ba129b7b900f09619981ef8a616bb3a798b95813 Mon Sep 17 00:00:00 2001 From: Dennis Lieu Date: Fri, 20 Apr 2018 02:14:33 +0200 Subject: [PATCH 1/5] [unity] Use public properties in examples. * Use public Rotation property instead of internal rotation field in code example to allow Spine to be imported in Plugins folder * Use public Attachment property instead of internal attachment field to allow Spine to be imported in Plugins folder --- .../Assets/Spine Examples/Scripts/SpineboyBodyTilt.cs | 6 +++--- .../Spine Examples/Scripts/SpineboyFacialExpression.cs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spine-unity/Assets/Spine Examples/Scripts/SpineboyBodyTilt.cs b/spine-unity/Assets/Spine Examples/Scripts/SpineboyBodyTilt.cs index 82c984ea2..878d5dfcb 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/SpineboyBodyTilt.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/SpineboyBodyTilt.cs @@ -27,7 +27,7 @@ namespace Spine.Unity.Examples { hipBone = skeleton.FindBone(hip); headBone = skeleton.FindBone(head); - baseHeadRotation = headBone.rotation; + baseHeadRotation = headBone.Rotation; skeletonAnimation.UpdateLocal += UpdateLocal; } @@ -35,8 +35,8 @@ namespace Spine.Unity.Examples { private void UpdateLocal (ISkeletonAnimation animated) { hipRotationTarget = planter.Balance * hipTiltScale; hipRotationSmoothed = Mathf.MoveTowards(hipRotationSmoothed, hipRotationTarget, Time.deltaTime * hipRotationMoveScale * Mathf.Abs(2f * planter.Balance / planter.offBalanceThreshold)); - hipBone.rotation = hipRotationSmoothed; - headBone.rotation = baseHeadRotation + (-hipRotationSmoothed * headTiltScale); + hipBone.Rotation = hipRotationSmoothed; + headBone.Rotation = baseHeadRotation + (-hipRotationSmoothed * headTiltScale); } } diff --git a/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs b/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs index 6a0ed3fd6..48b2b7dc0 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/SpineboyFacialExpression.cs @@ -48,11 +48,11 @@ namespace Spine.Unity.Examples { shockTimer -= Time.deltaTime; if (shockTimer > 0) { - eyeSlot.attachment = shockEye; - mouthSlot.attachment = shockMouth; + eyeSlot.Attachment = shockEye; + mouthSlot.Attachment = shockMouth; } else { - eyeSlot.attachment = normalEye; - mouthSlot.attachment = normalMouth; + eyeSlot.Attachment = normalEye; + mouthSlot.Attachment = normalMouth; } } } From 69cb86eeefe5e7cb145c46ca282cc2930dd46e41 Mon Sep 17 00:00:00 2001 From: pharan Date: Fri, 20 Apr 2018 12:05:02 +0800 Subject: [PATCH 2/5] [unity] Add PointAttachment icon to editor. --- .../spine-unity/Editor/GUI/icon-point.png | Bin 0 -> 687 bytes .../Editor/GUI/icon-point.png.meta | 92 ++++++++++++++++++ .../Editor/SpineEditorUtilities.cs | 4 + 3 files changed, 96 insertions(+) create mode 100644 spine-unity/Assets/spine-unity/Editor/GUI/icon-point.png create mode 100644 spine-unity/Assets/spine-unity/Editor/GUI/icon-point.png.meta diff --git a/spine-unity/Assets/spine-unity/Editor/GUI/icon-point.png b/spine-unity/Assets/spine-unity/Editor/GUI/icon-point.png new file mode 100644 index 0000000000000000000000000000000000000000..0e5099f4db3b09ce4eca59a327cc3a086e104e2b GIT binary patch literal 687 zcmV;g0#N;lP)3AX4OSEeSyp)WYL8pE`69>H{G-l z>TbwJf^nf>5)gGEPGVYY`_6- zm^TCDbGh8X>FMbw5s_}UJ2wvY0cSC619@Nz*aHsCyW_g<;~)q=h=?2=9es2h=S2_% z0kCZZuz?NF^L(XLCk(?#Yb{|IMvX?JQ!EyrpPZb$X*QefOeV7rlw8-n2i!8QS@S&4 z@AZ1;T5E}-NKYn{G>&7PB#E@!?Vp80;TiAG8_&seBW1|=RNg( z|J7(Tx=7Ph8jVH=*a0$E2m!DchT%MpV_mD&6z~wZ1C;Ca`f(IRIt;_e+{C$x*#>g! z>+4zDwrRCm?|{$12>8-!wcaL4LO!2&f!wm~WyZ6?U=RaTDwPL7$v7yL%jNBCHp_50 zoC7mpW$u69;Oy+|qF%2b@9yrtJUl#Xj>qF9O;b@ybqr#AMN Date: Fri, 20 Apr 2018 12:05:32 +0800 Subject: [PATCH 3/5] [unity] Minor updates to editors. --- .../Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs | 6 ++++++ .../Assets/spine-unity/Editor/SpineAttributeDrawers.cs | 1 + .../Assets/spine-unity/Editor/SpineEditorUtilities.cs | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs b/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs index 34892081b..4219b27ab 100644 --- a/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs +++ b/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs @@ -238,6 +238,12 @@ namespace Spine.Unity.Editor { AssetDatabase.CreateAsset(newAsset, assetPath); } } + + var folderObject = AssetDatabase.LoadAssetAtPath(dataPath, typeof(UnityEngine.Object)); + if (folderObject != null) { + Selection.activeObject = folderObject; + EditorGUIUtility.PingObject(folderObject); + } } void OnInspectorGUIMulti () { diff --git a/spine-unity/Assets/spine-unity/Editor/SpineAttributeDrawers.cs b/spine-unity/Assets/spine-unity/Editor/SpineAttributeDrawers.cs index 846113088..3eafcd243 100644 --- a/spine-unity/Assets/spine-unity/Editor/SpineAttributeDrawers.cs +++ b/spine-unity/Assets/spine-unity/Editor/SpineAttributeDrawers.cs @@ -75,6 +75,7 @@ namespace Spine.Unity.Editor { } SerializedProperty dataField = property.FindBaseOrSiblingProperty(TargetAttribute.dataField); + if (dataField != null) { var objectReferenceValue = dataField.objectReferenceValue; if (objectReferenceValue is SkeletonDataAsset) { diff --git a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs index d524129de..04fe68b8d 100644 --- a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs +++ b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs @@ -288,7 +288,6 @@ namespace Spine.Unity.Editor { defaultShader = shader != null ? shader.name : DEFAULT_DEFAULT_SHADER; if (EditorGUI.EndChangeCheck()) EditorPrefs.SetString(DEFAULT_SHADER_KEY, defaultShader); - EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); setTextureImporterSettings = EditorGUILayout.Toggle(new GUIContent("Apply Atlas Texture Settings", "Apply the recommended settings for Texture Importers."), showHierarchyIcons); @@ -296,6 +295,8 @@ namespace Spine.Unity.Editor { EditorPrefs.SetBool(SET_TEXTUREIMPORTER_SETTINGS_KEY, showHierarchyIcons); } + EditorGUILayout.Space(); + EditorGUILayout.LabelField("Editor Instantiation", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); defaultZSpacing = EditorGUILayout.Slider("Default Slot Z-Spacing", defaultZSpacing, -0.1f, 0f); From 1e7b9a10833dc9aaa53387f607b4a4aeecf32b60 Mon Sep 17 00:00:00 2001 From: pharan Date: Fri, 20 Apr 2018 12:17:46 +0800 Subject: [PATCH 4/5] [csharp] Make AnimationPair nested type public. --- spine-csharp/src/AnimationStateData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spine-csharp/src/AnimationStateData.cs b/spine-csharp/src/AnimationStateData.cs index 5282d894c..0e0cf8bc7 100644 --- a/spine-csharp/src/AnimationStateData.cs +++ b/spine-csharp/src/AnimationStateData.cs @@ -83,7 +83,7 @@ namespace Spine { return defaultMix; } - struct AnimationPair { + public struct AnimationPair { public readonly Animation a1; public readonly Animation a2; @@ -98,8 +98,8 @@ namespace Spine { } // Avoids boxing in the dictionary. - class AnimationPairComparer : IEqualityComparer { - internal static readonly AnimationPairComparer Instance = new AnimationPairComparer(); + public class AnimationPairComparer : IEqualityComparer { + public static readonly AnimationPairComparer Instance = new AnimationPairComparer(); bool IEqualityComparer.Equals (AnimationPair x, AnimationPair y) { return ReferenceEquals(x.a1, y.a1) && ReferenceEquals(x.a2, y.a2); From 7e910cb8f7e2a266d5c072b55a726a02c30e39de Mon Sep 17 00:00:00 2001 From: pharan Date: Fri, 20 Apr 2018 12:18:36 +0800 Subject: [PATCH 5/5] [csharp] Minor cleanup. --- spine-csharp/src/AnimationStateData.cs | 6 +++--- spine-csharp/src/Bone.cs | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/spine-csharp/src/AnimationStateData.cs b/spine-csharp/src/AnimationStateData.cs index 0e0cf8bc7..f3ad87183 100644 --- a/spine-csharp/src/AnimationStateData.cs +++ b/spine-csharp/src/AnimationStateData.cs @@ -47,16 +47,16 @@ namespace Spine { public float DefaultMix { get { return defaultMix; } set { defaultMix = value; } } public AnimationStateData (SkeletonData skeletonData) { - if (skeletonData == null) throw new ArgumentException ("skeletonData cannot be null."); + if (skeletonData == null) throw new ArgumentException("skeletonData cannot be null.", "skeletonData"); this.skeletonData = skeletonData; } /// Sets a mix duration by animation names. public void SetMix (string fromName, string toName, float duration) { Animation from = skeletonData.FindAnimation(fromName); - if (from == null) throw new ArgumentException("Animation not found: " + fromName); + if (from == null) throw new ArgumentException("Animation not found: " + fromName, "fromName"); Animation to = skeletonData.FindAnimation(toName); - if (to == null) throw new ArgumentException("Animation not found: " + toName); + if (to == null) throw new ArgumentException("Animation not found: " + toName, "toName"); SetMix(from, to, duration); } diff --git a/spine-csharp/src/Bone.cs b/spine-csharp/src/Bone.cs index 8a68cc203..3357ec3c0 100644 --- a/spine-csharp/src/Bone.cs +++ b/spine-csharp/src/Bone.cs @@ -173,16 +173,12 @@ namespace Spine { d = ld; worldX = x + skeleton.x; worldY = y + skeleton.y; -// worldSignX = Math.Sign(scaleX); -// worldSignY = Math.Sign(scaleY); return; } float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; worldX = pa * x + pb * y + parent.worldX; worldY = pc * x + pd * y + parent.worldY; -// worldSignX = parent.worldSignX * Math.Sign(scaleX); -// worldSignY = parent.worldSignY * Math.Sign(scaleY); switch (data.transformMode) { case TransformMode.Normal: {