From 38e54e686db899b6c4fa5e259620bb890322de59 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Wed, 5 Feb 2014 20:23:34 +0100 Subject: [PATCH] Added BoneComponent. closes #166 --- spine-tk2d/Assets/Spine/BoneComponent.cs | 67 ++++++++++++++++ spine-tk2d/Assets/Spine/BoneComponent.cs.meta | 8 ++ .../Spine/Editor/BoneComponentInspector.cs | 72 ++++++++++++++++++ .../Editor/BoneComponentInspector.cs.meta | 8 ++ spine-tk2d/Assets/Spine/Editor/Menus.cs | 22 ------ spine-tk2d/Assets/Spine/SkeletonAnimation.cs | 1 + spine-tk2d/Assets/Spine/SkeletonComponent.cs | 1 + .../Assets/examples/spineboy/spineboy.unity | Bin 21680 -> 23640 bytes spine-unity/Assets/Spine/BoneComponent.cs | 67 ++++++++++++++++ .../Assets/Spine/BoneComponent.cs.meta | 8 ++ .../Spine/Editor/BoneComponentInspector.cs | 72 ++++++++++++++++++ .../Editor/BoneComponentInspector.cs.meta | 8 ++ spine-unity/Assets/Spine/Editor/Menus.cs | 22 ------ spine-unity/Assets/Spine/SkeletonAnimation.cs | 1 + spine-unity/Assets/Spine/SkeletonComponent.cs | 1 + .../Assets/examples/spineboy/spineboy.unity | Bin 18696 -> 20696 bytes 16 files changed, 314 insertions(+), 44 deletions(-) create mode 100644 spine-tk2d/Assets/Spine/BoneComponent.cs create mode 100644 spine-tk2d/Assets/Spine/BoneComponent.cs.meta create mode 100644 spine-tk2d/Assets/Spine/Editor/BoneComponentInspector.cs create mode 100644 spine-tk2d/Assets/Spine/Editor/BoneComponentInspector.cs.meta create mode 100644 spine-unity/Assets/Spine/BoneComponent.cs create mode 100644 spine-unity/Assets/Spine/BoneComponent.cs.meta create mode 100644 spine-unity/Assets/Spine/Editor/BoneComponentInspector.cs create mode 100644 spine-unity/Assets/Spine/Editor/BoneComponentInspector.cs.meta diff --git a/spine-tk2d/Assets/Spine/BoneComponent.cs b/spine-tk2d/Assets/Spine/BoneComponent.cs new file mode 100644 index 000000000..e24350b70 --- /dev/null +++ b/spine-tk2d/Assets/Spine/BoneComponent.cs @@ -0,0 +1,67 @@ +/****************************************************************************** + * Spine Runtimes Software License + * Version 2 + * + * Copyright (c) 2013, Esoteric Software + * All rights reserved. + * + * You are granted a perpetual, non-exclusive, non-sublicensable and + * non-transferable license to install, execute and perform the Spine Runtimes + * Software (the "Software") solely for internal use. Without the written + * permission of Esoteric Software, you may not (a) modify, translate, adapt or + * otherwise create derivative works, improvements of the Software or develop + * new applications using the Software or (b) remove, delete, alter or obscure + * any trademarks or any copyright, trademark, patent or other intellectual + * property or proprietary rights notices on or in the Software, including + * any copy thereof. Redistributions in binary or source form must include + * this license and terms. THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System; +using System.IO; +using System.Collections.Generic; +using UnityEngine; +using Spine; + +/// Sets a GameObject's transform to match a bone on a Spine skeleton. +[ExecuteInEditMode] +[AddComponentMenu("Spine/BoneComponent")] +public class BoneComponent : MonoBehaviour { + public SkeletonComponent skeletonComponent; + public Bone bone; + + /// If a bone isn't set, boneName is used to find the bone. + public String boneName; + + public void LateUpdate () { + if (skeletonComponent == null) return; + if (bone == null) { + if (boneName == null) return; + bone = skeletonComponent.skeleton.FindBone(boneName); + if (bone == null) { + Debug.Log("Bone not found: " + boneName, this); + return; + } + } + if (transform.parent == skeletonComponent.transform) { + transform.localPosition = new Vector3(bone.worldX, bone.worldY, transform.localPosition.z); + Vector3 rotation = transform.localRotation.eulerAngles; + transform.localRotation = Quaternion.Euler(rotation.x, rotation.y, bone.worldRotation); + } else { + // Best effort to set this GameObject's transform when it isn't a child of the SkeletonComponent. + transform.position = skeletonComponent.transform.TransformPoint(new Vector3(bone.worldX, bone.worldY, transform.position.z)); + Vector3 rotation = skeletonComponent.transform.rotation.eulerAngles; + transform.rotation = Quaternion.Euler(rotation.x, rotation.y, + skeletonComponent.transform.rotation.eulerAngles.z + bone.worldRotation); + } + } +} \ No newline at end of file diff --git a/spine-tk2d/Assets/Spine/BoneComponent.cs.meta b/spine-tk2d/Assets/Spine/BoneComponent.cs.meta new file mode 100644 index 000000000..f2c537209 --- /dev/null +++ b/spine-tk2d/Assets/Spine/BoneComponent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d08aa5caf52eae44ba81cc81ca1dad5d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/spine-tk2d/Assets/Spine/Editor/BoneComponentInspector.cs b/spine-tk2d/Assets/Spine/Editor/BoneComponentInspector.cs new file mode 100644 index 000000000..c30ff1ace --- /dev/null +++ b/spine-tk2d/Assets/Spine/Editor/BoneComponentInspector.cs @@ -0,0 +1,72 @@ +/****************************************************************************** + * Spine Runtimes Software License + * Version 2 + * + * Copyright (c) 2013, Esoteric Software + * All rights reserved. + * + * You are granted a perpetual, non-exclusive, non-sublicensable and + * non-transferable license to install, execute and perform the Spine Runtimes + * Software (the "Software") solely for internal use. Without the written + * permission of Esoteric Software, you may not (a) modify, translate, adapt or + * otherwise create derivative works, improvements of the Software or develop + * new applications using the Software or (b) remove, delete, alter or obscure + * any trademarks or any copyright, trademark, patent or other intellectual + * property or proprietary rights notices on or in the Software, including + * any copy thereof. Redistributions in binary or source form must include + * this license and terms. THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System; +using UnityEditor; +using UnityEngine; + +[CustomEditor(typeof(BoneComponent))] +public class BoneComponentInspector : Editor { + private SerializedProperty boneName, skeletonComponent; + + void OnEnable () { + skeletonComponent = serializedObject.FindProperty("skeletonComponent"); + boneName = serializedObject.FindProperty("boneName"); + } + + override public void OnInspectorGUI () { + serializedObject.Update(); + BoneComponent component = (BoneComponent)target; + + EditorGUILayout.PropertyField(skeletonComponent); + + if (component.skeletonComponent != null) { + String[] bones = new String[component.skeletonComponent.skeleton.Data.Bones.Count + 1]; + bones[0] = ""; + for (int i = 0; i < bones.Length - 1; i++) + bones[i + 1] = component.skeletonComponent.skeleton.Data.Bones[i].Name; + Array.Sort(bones); + int boneIndex = Math.Max(0, Array.IndexOf(bones, boneName.stringValue)); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Bone"); + EditorGUIUtility.LookLikeControls(); + boneIndex = EditorGUILayout.Popup(boneIndex, bones); + EditorGUILayout.EndHorizontal(); + + boneName.stringValue = bones[boneIndex];; + } + + if (serializedObject.ApplyModifiedProperties() || + (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") + ) { + component.bone = null; + component.LateUpdate(); + } + } +} diff --git a/spine-tk2d/Assets/Spine/Editor/BoneComponentInspector.cs.meta b/spine-tk2d/Assets/Spine/Editor/BoneComponentInspector.cs.meta new file mode 100644 index 000000000..7a90e80a3 --- /dev/null +++ b/spine-tk2d/Assets/Spine/Editor/BoneComponentInspector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 99e3e8311529bbc48a5c3a5b9714e162 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/spine-tk2d/Assets/Spine/Editor/Menus.cs b/spine-tk2d/Assets/Spine/Editor/Menus.cs index 2737e1f9b..fdd3d26c5 100644 --- a/spine-tk2d/Assets/Spine/Editor/Menus.cs +++ b/spine-tk2d/Assets/Spine/Editor/Menus.cs @@ -64,26 +64,4 @@ public class Menus { EditorUtility.FocusProjectWindow(); Selection.activeObject = gameObject; } - - [MenuItem("Component/Spine SkeletonComponent")] - static public void CreateSkeletonComponent () { - Selection.activeGameObject.AddComponent(typeof(SkeletonComponent)); - } - - [MenuItem("Component/Spine SkeletonAnimation")] - static public void CreateSkeletonAnimation () { - Selection.activeGameObject.AddComponent(typeof(SkeletonAnimation)); - } - - [MenuItem("Component/Spine SkeletonComponent", true)] - static public bool ValidateCreateSkeletonComponent () { - return Selection.activeGameObject != null - && Selection.activeGameObject.GetComponent(typeof(SkeletonComponent)) == null - && Selection.activeGameObject.GetComponent(typeof(SkeletonAnimation)) == null; - } - - [MenuItem("Component/Spine SkeletonAnimation", true)] - static public bool ValidateCreateSkeletonAnimation () { - return ValidateCreateSkeletonComponent(); - } } diff --git a/spine-tk2d/Assets/Spine/SkeletonAnimation.cs b/spine-tk2d/Assets/Spine/SkeletonAnimation.cs index 5c9cd68f6..e7376fa7b 100644 --- a/spine-tk2d/Assets/Spine/SkeletonAnimation.cs +++ b/spine-tk2d/Assets/Spine/SkeletonAnimation.cs @@ -34,6 +34,7 @@ using Spine; /** Extends SkeletonComponent to apply an animation. */ [ExecuteInEditMode, RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] +[AddComponentMenu("Spine/SkeletonAnimation")] public class SkeletonAnimation : SkeletonComponent { public bool loop; public Spine.AnimationState state; diff --git a/spine-tk2d/Assets/Spine/SkeletonComponent.cs b/spine-tk2d/Assets/Spine/SkeletonComponent.cs index 5868419f1..8813c138c 100644 --- a/spine-tk2d/Assets/Spine/SkeletonComponent.cs +++ b/spine-tk2d/Assets/Spine/SkeletonComponent.cs @@ -34,6 +34,7 @@ using Spine; /** Renders a skeleton. Extend to apply animations, get bones and manipulate them, etc. */ [ExecuteInEditMode, RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] +[AddComponentMenu("Spine/SkeletonComponent")] public class SkeletonComponent : MonoBehaviour { public SkeletonDataAsset skeletonDataAsset; public Skeleton skeleton; diff --git a/spine-tk2d/Assets/examples/spineboy/spineboy.unity b/spine-tk2d/Assets/examples/spineboy/spineboy.unity index 3313c26fa8b75a5a70ccc7def9d87ad826a796a2..6bf827569a72283ebd019ea63d81877b0aee7393 100644 GIT binary patch delta 885 zcmZ9KO=uHQ5Xa}qwrK?H*zVJi`(he~S>xo8q1Xz79*VxdUI8jP((HxkoBAdnnN z+r*3VTF)L83$8?^H^GY+g(?)Je&VSV)YOw8HU7taE75`fzBj+jn|U)Y&OPyFNgO0f zza|g{#*JcFryxr|bFL zm0YP{dq~Fhyq3j}^07YsFmhl>81m%M&noBFlosC2L>xF#_*|lh^)}cVSOWW`(#+e+ zvBOSOt4LruMRc}HV(F%sLCH|@L|9N_Fj=2U_ZbjV7*FT zton$t_20r@!5lCHF=?f5V9SbCz*sG?mSSV@SsPZhJ`&W4Y&g4=z9X;(*4c@Erx^$1CRlzj2P}cT*GLao3#_w|09eS68UX})&dR___B3Pm}BAXA4jC6j3csbO&`jxpDLO zqu^GdK|btV74xP~VWbZ$(0Wum=5% pFj`tYgdBUC)9E!4?14W~EKL31m2@)u1ZSG<{(B@0sL9Hi=x^an&x-&6 delta 387 zcmcbygK@)3Mnwh&AAJUfkPQqB44goA0FY)d(KFUFNi$^l_y7NY!Odo@s-BEelVkjT zCxK*Hpm^$?HkB1XjtP(tQdk6}rvb$t0L2`DY)2@58_*f5z{2-ibpVt_Ir{1GT4z{bFk2V{#t@h6~I15gavMI8F~vo8R}3V~{1 zHgN*QJlGi+5`bdjP|O7sTLBbv0PE5{&GV TYa^V&ygktlj2x5yMn?kxm!MV% diff --git a/spine-unity/Assets/Spine/BoneComponent.cs b/spine-unity/Assets/Spine/BoneComponent.cs new file mode 100644 index 000000000..e24350b70 --- /dev/null +++ b/spine-unity/Assets/Spine/BoneComponent.cs @@ -0,0 +1,67 @@ +/****************************************************************************** + * Spine Runtimes Software License + * Version 2 + * + * Copyright (c) 2013, Esoteric Software + * All rights reserved. + * + * You are granted a perpetual, non-exclusive, non-sublicensable and + * non-transferable license to install, execute and perform the Spine Runtimes + * Software (the "Software") solely for internal use. Without the written + * permission of Esoteric Software, you may not (a) modify, translate, adapt or + * otherwise create derivative works, improvements of the Software or develop + * new applications using the Software or (b) remove, delete, alter or obscure + * any trademarks or any copyright, trademark, patent or other intellectual + * property or proprietary rights notices on or in the Software, including + * any copy thereof. Redistributions in binary or source form must include + * this license and terms. THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System; +using System.IO; +using System.Collections.Generic; +using UnityEngine; +using Spine; + +/// Sets a GameObject's transform to match a bone on a Spine skeleton. +[ExecuteInEditMode] +[AddComponentMenu("Spine/BoneComponent")] +public class BoneComponent : MonoBehaviour { + public SkeletonComponent skeletonComponent; + public Bone bone; + + /// If a bone isn't set, boneName is used to find the bone. + public String boneName; + + public void LateUpdate () { + if (skeletonComponent == null) return; + if (bone == null) { + if (boneName == null) return; + bone = skeletonComponent.skeleton.FindBone(boneName); + if (bone == null) { + Debug.Log("Bone not found: " + boneName, this); + return; + } + } + if (transform.parent == skeletonComponent.transform) { + transform.localPosition = new Vector3(bone.worldX, bone.worldY, transform.localPosition.z); + Vector3 rotation = transform.localRotation.eulerAngles; + transform.localRotation = Quaternion.Euler(rotation.x, rotation.y, bone.worldRotation); + } else { + // Best effort to set this GameObject's transform when it isn't a child of the SkeletonComponent. + transform.position = skeletonComponent.transform.TransformPoint(new Vector3(bone.worldX, bone.worldY, transform.position.z)); + Vector3 rotation = skeletonComponent.transform.rotation.eulerAngles; + transform.rotation = Quaternion.Euler(rotation.x, rotation.y, + skeletonComponent.transform.rotation.eulerAngles.z + bone.worldRotation); + } + } +} \ No newline at end of file diff --git a/spine-unity/Assets/Spine/BoneComponent.cs.meta b/spine-unity/Assets/Spine/BoneComponent.cs.meta new file mode 100644 index 000000000..a6a16dd66 --- /dev/null +++ b/spine-unity/Assets/Spine/BoneComponent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 487b42efe96d8cc408a757541ea3f169 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/spine-unity/Assets/Spine/Editor/BoneComponentInspector.cs b/spine-unity/Assets/Spine/Editor/BoneComponentInspector.cs new file mode 100644 index 000000000..c30ff1ace --- /dev/null +++ b/spine-unity/Assets/Spine/Editor/BoneComponentInspector.cs @@ -0,0 +1,72 @@ +/****************************************************************************** + * Spine Runtimes Software License + * Version 2 + * + * Copyright (c) 2013, Esoteric Software + * All rights reserved. + * + * You are granted a perpetual, non-exclusive, non-sublicensable and + * non-transferable license to install, execute and perform the Spine Runtimes + * Software (the "Software") solely for internal use. Without the written + * permission of Esoteric Software, you may not (a) modify, translate, adapt or + * otherwise create derivative works, improvements of the Software or develop + * new applications using the Software or (b) remove, delete, alter or obscure + * any trademarks or any copyright, trademark, patent or other intellectual + * property or proprietary rights notices on or in the Software, including + * any copy thereof. Redistributions in binary or source form must include + * this license and terms. THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System; +using UnityEditor; +using UnityEngine; + +[CustomEditor(typeof(BoneComponent))] +public class BoneComponentInspector : Editor { + private SerializedProperty boneName, skeletonComponent; + + void OnEnable () { + skeletonComponent = serializedObject.FindProperty("skeletonComponent"); + boneName = serializedObject.FindProperty("boneName"); + } + + override public void OnInspectorGUI () { + serializedObject.Update(); + BoneComponent component = (BoneComponent)target; + + EditorGUILayout.PropertyField(skeletonComponent); + + if (component.skeletonComponent != null) { + String[] bones = new String[component.skeletonComponent.skeleton.Data.Bones.Count + 1]; + bones[0] = ""; + for (int i = 0; i < bones.Length - 1; i++) + bones[i + 1] = component.skeletonComponent.skeleton.Data.Bones[i].Name; + Array.Sort(bones); + int boneIndex = Math.Max(0, Array.IndexOf(bones, boneName.stringValue)); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Bone"); + EditorGUIUtility.LookLikeControls(); + boneIndex = EditorGUILayout.Popup(boneIndex, bones); + EditorGUILayout.EndHorizontal(); + + boneName.stringValue = bones[boneIndex];; + } + + if (serializedObject.ApplyModifiedProperties() || + (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") + ) { + component.bone = null; + component.LateUpdate(); + } + } +} diff --git a/spine-unity/Assets/Spine/Editor/BoneComponentInspector.cs.meta b/spine-unity/Assets/Spine/Editor/BoneComponentInspector.cs.meta new file mode 100644 index 000000000..1b03fab20 --- /dev/null +++ b/spine-unity/Assets/Spine/Editor/BoneComponentInspector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dca21b77745bb4245a4e2e012c282ce6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/spine-unity/Assets/Spine/Editor/Menus.cs b/spine-unity/Assets/Spine/Editor/Menus.cs index 8d86a9c36..dcacb74aa 100644 --- a/spine-unity/Assets/Spine/Editor/Menus.cs +++ b/spine-unity/Assets/Spine/Editor/Menus.cs @@ -69,26 +69,4 @@ public class SpineEditor { EditorUtility.FocusProjectWindow(); Selection.activeObject = gameObject; } - - [MenuItem("Component/Spine SkeletonComponent")] - static public void CreateSkeletonComponent () { - Selection.activeGameObject.AddComponent(typeof(SkeletonComponent)); - } - - [MenuItem("Component/Spine SkeletonAnimation")] - static public void CreateSkeletonAnimation () { - Selection.activeGameObject.AddComponent(typeof(SkeletonAnimation)); - } - - [MenuItem("Component/Spine SkeletonComponent", true)] - static public bool ValidateCreateSkeletonComponent () { - return Selection.activeGameObject != null - && Selection.activeGameObject.GetComponent(typeof(SkeletonComponent)) == null - && Selection.activeGameObject.GetComponent(typeof(SkeletonAnimation)) == null; - } - - [MenuItem("Component/Spine SkeletonAnimation", true)] - static public bool ValidateCreateSkeletonAnimation () { - return ValidateCreateSkeletonComponent(); - } } diff --git a/spine-unity/Assets/Spine/SkeletonAnimation.cs b/spine-unity/Assets/Spine/SkeletonAnimation.cs index fb5971fcb..64d82b75f 100644 --- a/spine-unity/Assets/Spine/SkeletonAnimation.cs +++ b/spine-unity/Assets/Spine/SkeletonAnimation.cs @@ -34,6 +34,7 @@ using Spine; /** Extends SkeletonComponent to apply an animation. */ [ExecuteInEditMode, RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] +[AddComponentMenu("Spine/SkeletonAnimation")] public class SkeletonAnimation : SkeletonComponent { public bool loop; public Spine.AnimationState state; diff --git a/spine-unity/Assets/Spine/SkeletonComponent.cs b/spine-unity/Assets/Spine/SkeletonComponent.cs index fe27dceb5..0c7cc4ada 100644 --- a/spine-unity/Assets/Spine/SkeletonComponent.cs +++ b/spine-unity/Assets/Spine/SkeletonComponent.cs @@ -34,6 +34,7 @@ using Spine; /** Renders a skeleton. Extend to apply animations, get bones and manipulate them, etc. */ [ExecuteInEditMode, RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] +[AddComponentMenu("Spine/SkeletonComponent")] public class SkeletonComponent : MonoBehaviour { public SkeletonDataAsset skeletonDataAsset; public Skeleton skeleton; diff --git a/spine-unity/Assets/examples/spineboy/spineboy.unity b/spine-unity/Assets/examples/spineboy/spineboy.unity index 49501911ac79401284b2522338d1047129e1654b..0eef947c90f1e73484f09efe372700f5c6ee3b3b 100644 GIT binary patch delta 784 zcmYk3OKTHR6vxk`Q(Hr*hz09|IMzs^i`r@yMbNxxnreht6-0bAF;f!~Co-7N zi$tWqq~>ra7W)@ohvs6+ka!Slo;r^-s?@tb-%s4^A&SC}NiBiB2MfdJvL@Ca>H3v* zut(S{Qa`~Q@g%v!*@H%e7kVF4(6?N z8f<(EQ5tb=+0iVR12#vLq@6fmodIkCMzMFtISZ!s5rx3^OPvEtfq4t}iQjQ^W??C` z@nU5;?cB1bz8>B895Z`tz_TwGb7t189kPw0RnzkNeAX^onyFVSws}>rifm$6<9=ec zC&2H;#zjFj;UohMbz1d_R&r33rvoSXgj-|dcDZ#n9*4(b<9Yc{ujQw2EKt1d^DD0cW(EcaAm0&+w*$pC0L4sze30fMApP2BLHrA#SSOIp2*q!JViiDx z6oC9dD1HkRn*kN80g8d}JD}JOs8|dGgB}BrV0aG{ya5!<1F}V+_ybVPgOz~+*@3K+ e>pY4kZ}XJj9ON0qJlVpFfARrO(ajfp1egFzuR2cv