From 69f37c2a4815c6e54ecf208cfeab60de951e6194 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Tue, 14 May 2013 01:36:50 +0200 Subject: [PATCH 1/3] SpineboyComponent renamed to Spineboy. --- .../spine/AnimationStateTest.java | 16 +++++++ .../esotericsoftware/spine/SkeletonTest.java | 15 ++++--- .../Unity 3.5/spineboy/SpineboyComponent.cs | 43 ------------------- .../spineboy/SpineboyComponent.cs.meta | 7 --- 4 files changed, 25 insertions(+), 56 deletions(-) delete mode 100644 spine-unity/Assets/examples/Unity 3.5/spineboy/SpineboyComponent.cs delete mode 100644 spine-unity/Assets/examples/Unity 3.5/spineboy/SpineboyComponent.cs.meta diff --git a/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java b/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java index 2d4d54efe..249516ff4 100644 --- a/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java +++ b/spine-libgdx/test/com/esotericsoftware/spine/AnimationStateTest.java @@ -27,6 +27,8 @@ package com.esotericsoftware.spine; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.InputAdapter; +import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.g2d.SpriteBatch; @@ -56,6 +58,7 @@ public class AnimationStateTest extends ApplicationAdapter { AnimationStateData stateData = new AnimationStateData(skeletonData); stateData.setMix("walk", "jump", 0.2f); stateData.setMix("jump", "walk", 0.4f); + stateData.setMix("jump", "jump", 0.2f); state = new AnimationState(stateData); state.setAnimation("walk", true); @@ -67,6 +70,19 @@ public class AnimationStateTest extends ApplicationAdapter { root.setY(20); skeleton.updateWorldTransform(); + + Gdx.input.setInputProcessor(new InputAdapter() { + public boolean touchDown (int screenX, int screenY, int pointer, int button) { + keyDown(0); + return true; + } + + public boolean keyDown (int keycode) { + state.setAnimation("jump", false); + state.addAnimation("walk", true); + return true; + } + }); } public void render () { diff --git a/spine-libgdx/test/com/esotericsoftware/spine/SkeletonTest.java b/spine-libgdx/test/com/esotericsoftware/spine/SkeletonTest.java index 9673cf19c..fdf6e3486 100644 --- a/spine-libgdx/test/com/esotericsoftware/spine/SkeletonTest.java +++ b/spine-libgdx/test/com/esotericsoftware/spine/SkeletonTest.java @@ -99,12 +99,15 @@ public class SkeletonTest extends ApplicationAdapter { skeleton.updateWorldTransform(); Gdx.input.setInputProcessor(new InputAdapter() { + public boolean touchDown (int screenX, int screenY, int pointer, int button) { + keyDown(0); + return true; + } + public boolean keyDown (int keycode) { - if (keycode == Keys.SPACE) { - if (name.equals("goblins")) { - skeleton.setSkin(skeleton.getSkin().getName().equals("goblin") ? "goblingirl" : "goblin"); - skeleton.setSlotsToSetupPose(); - } + if (name.equals("goblins")) { + skeleton.setSkin(skeleton.getSkin().getName().equals("goblin") ? "goblingirl" : "goblin"); + skeleton.setSlotsToSetupPose(); } return true; } @@ -122,7 +125,7 @@ public class SkeletonTest extends ApplicationAdapter { Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); - animation.apply(skeleton, time, true); + animation.apply(skeleton, time, false); skeleton.updateWorldTransform(); skeleton.update(Gdx.graphics.getDeltaTime()); diff --git a/spine-unity/Assets/examples/Unity 3.5/spineboy/SpineboyComponent.cs b/spine-unity/Assets/examples/Unity 3.5/spineboy/SpineboyComponent.cs deleted file mode 100644 index 74680081e..000000000 --- a/spine-unity/Assets/examples/Unity 3.5/spineboy/SpineboyComponent.cs +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, Esoteric Software - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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 UnityEngine; -using System.Collections; - -public class SpineboyComponent : MonoBehaviour { - public void OnMouseDown () { - SkeletonComponent skeletonComponent = GetComponent(); - skeletonComponent.animationName = "jump"; - skeletonComponent.loop = false; - } - - public void Update () { - SkeletonComponent skeletonComponent = GetComponent(); - if (!skeletonComponent.loop && skeletonComponent.state.Time >= skeletonComponent.state.Animation.Duration - 0.25) { - skeletonComponent.animationName = "walk"; - skeletonComponent.loop = true; - } - } -} diff --git a/spine-unity/Assets/examples/Unity 3.5/spineboy/SpineboyComponent.cs.meta b/spine-unity/Assets/examples/Unity 3.5/spineboy/SpineboyComponent.cs.meta deleted file mode 100644 index 758647ce6..000000000 --- a/spine-unity/Assets/examples/Unity 3.5/spineboy/SpineboyComponent.cs.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1f998efe00dbbc246afece8f6a849fc6 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} From d1d1c6a638d98ea49af5474abe097cc68126233b Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Tue, 14 May 2013 15:02:22 +0200 Subject: [PATCH 2/3] Added Skin_getAttachmentName to enumerate skin attachments for a slot. Thanks James Poag! --- spine-c/include/spine/Skin.h | 3 +++ spine-c/src/spine/Skin.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/spine-c/include/spine/Skin.h b/spine-c/include/spine/Skin.h index 649b15574..6fb3de156 100644 --- a/spine-c/include/spine/Skin.h +++ b/spine-c/include/spine/Skin.h @@ -46,6 +46,9 @@ void Skin_addAttachment (Skin* self, int slotIndex, const char* name, Attachment /* Returns 0 if the attachment was not found. */ Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* name); +/* Returns 0 if the slot or attachment was not found. */ +const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachmentIndex); + /** Attach each attachment in this skin if the corresponding attachment in oldSkin is currently attached. */ void Skin_attachAll (const Skin* self, struct Skeleton* skeleton, const Skin* oldSkin); diff --git a/spine-c/src/spine/Skin.c b/spine-c/src/spine/Skin.c index c91814d91..2cec61bf4 100644 --- a/spine-c/src/spine/Skin.c +++ b/spine-c/src/spine/Skin.c @@ -88,6 +88,19 @@ Attachment* Skin_getAttachment (const Skin* self, int slotIndex, const char* nam return 0; } +const char* Skin_getAttachmentName (const Skin* self, int slotIndex, int attachmentIndex) { + const _Entry* entry = SUB_CAST(_Internal, self) ->entries; + int i = 0; + while (entry) { + if (entry->slotIndex == slotIndex) { + if (i == attachmentIndex) return entry->name; + i++; + } + entry = entry->next; + } + return 0; +} + void Skin_attachAll (const Skin* self, Skeleton* skeleton, const Skin* oldSkin) { const _Entry *entry = SUB_CAST(_Internal, oldSkin) ->entries; while (entry) { From 73f2407f9d62066ffa8186bbc820e29c3e8e6b6c Mon Sep 17 00:00:00 2001 From: Dgizusse Date: Wed, 15 May 2013 12:12:07 -0400 Subject: [PATCH 3/3] - Fixed source textures being included in the build along the atlas. ***NOT BACKWARD COMPATIBLE*** --- spine-tk2d/Code/tk2dSpineSkeleton.cs | 8 ++--- spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs | 8 +++-- .../tk2dSpineSkeletonDataAssetInspector.cs | 34 +++++++++++++++--- spine-tk2d/Example/Example.unity | Bin 17944 -> 17960 bytes .../Skeleton/SpineboySkeletonAsset.asset | Bin 4240 -> 4244 bytes 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/spine-tk2d/Code/tk2dSpineSkeleton.cs b/spine-tk2d/Code/tk2dSpineSkeleton.cs index 823d3eccd..e6ec81750 100644 --- a/spine-tk2d/Code/tk2dSpineSkeleton.cs +++ b/spine-tk2d/Code/tk2dSpineSkeleton.cs @@ -138,10 +138,10 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor mesh.uv = uvs; mesh.triangles = triangles; - if (skeletonDataAsset.sprites.normalGenerationMode != tk2dSpriteCollection.NormalGenerationMode.None) { + if (skeletonDataAsset.normalGenerationMode != tk2dSpriteCollection.NormalGenerationMode.None) { mesh.RecalculateNormals(); - if (skeletonDataAsset.sprites.normalGenerationMode == tk2dSpriteCollection.NormalGenerationMode.NormalsAndTangents) { + if (skeletonDataAsset.normalGenerationMode == tk2dSpriteCollection.NormalGenerationMode.NormalsAndTangents) { Vector4[] tangents = new Vector4[mesh.normals.Length]; for (int t = 0; t < tangents.Length; ++t) { tangents[t] = new Vector4(1, 0, 0, 1); @@ -150,7 +150,7 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor } } - renderer.sharedMaterial = skeletonDataAsset.sprites.spriteCollection.inst.materials[0]; + renderer.sharedMaterial = skeletonDataAsset.spritesData.inst.materials[0]; } /* @@ -203,7 +203,7 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor } public bool UsesSpriteCollection(tk2dSpriteCollectionData spriteCollection) { - return skeletonDataAsset.sprites.spriteCollection == spriteCollection; + return skeletonDataAsset.spritesData == spriteCollection; } public void ForceBuild() { diff --git a/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs b/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs index ddba8b969..b5b5f3ab7 100644 --- a/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs +++ b/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs @@ -9,7 +9,9 @@ public class tk2dSpineSkeletonDataAsset : ScriptableObject { /* */ - public tk2dSpriteCollection sprites; + public tk2dSpriteCollectionData spritesData; + public tk2dSpriteCollection.NormalGenerationMode normalGenerationMode = tk2dSpriteCollection.NormalGenerationMode.None; + public TextAsset skeletonJSON; public float scale = 1; @@ -42,7 +44,7 @@ public class tk2dSpineSkeletonDataAsset : ScriptableObject { /* */ private void MakeSkeletonAndAnimationData() { - if(sprites == null) { + if(spritesData == null) { Debug.LogWarning("Sprite collection not set for skeleton data asset: " + name,this); return; } @@ -52,7 +54,7 @@ public class tk2dSpineSkeletonDataAsset : ScriptableObject { return; } - SkeletonJson json = new SkeletonJson(new tk2dSpineAttachmentLoader(sprites.spriteCollection)); + SkeletonJson json = new SkeletonJson(new tk2dSpineAttachmentLoader(spritesData)); json.Scale = scale; try { diff --git a/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs b/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs index 286007fcc..cc97f67ce 100644 --- a/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs +++ b/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs @@ -10,18 +10,29 @@ public class tk2dSpineSkeletonDataAssetInspector : Editor { /* */ - private SerializedProperty sprites; private SerializedProperty skeletonJSON; private SerializedProperty scale; private SerializedProperty fromAnimation; private SerializedProperty toAnimation; private SerializedProperty duration; private bool showAnimationStateData = true; - + + private tk2dSpriteCollection sprites; + /* */ void OnEnable () { - sprites = serializedObject.FindProperty("sprites"); + + tk2dSpineSkeletonDataAsset skeletonDataAsset = target as tk2dSpineSkeletonDataAsset; + + if (skeletonDataAsset != null) { + tk2dSpriteCollectionData spritesData = skeletonDataAsset.spritesData; + + if (spritesData != null) { + sprites = AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath(spritesData.spriteCollectionGUID), typeof(tk2dSpriteCollection) ) as tk2dSpriteCollection; + } + } + skeletonJSON = serializedObject.FindProperty("skeletonJSON"); scale = serializedObject.FindProperty("scale"); fromAnimation = serializedObject.FindProperty("fromAnimation"); @@ -37,7 +48,22 @@ public class tk2dSpineSkeletonDataAssetInspector : Editor { tk2dSpineSkeletonDataAsset asset = target as tk2dSpineSkeletonDataAsset; EditorGUIUtility.LookLikeInspector(); - EditorGUILayout.PropertyField(sprites); + sprites = EditorGUILayout.ObjectField("Sprites", sprites, typeof(tk2dSpriteCollection), false) as tk2dSpriteCollection; + + if (sprites != null) { + SerializedProperty spritesData = serializedObject.FindProperty("spritesData"); + spritesData.objectReferenceValue = sprites.spriteCollection; + + SerializedProperty normalGenerationMode = serializedObject.FindProperty("normalGenerationMode"); + normalGenerationMode.enumValueIndex = (int)sprites.normalGenerationMode; + } else { + SerializedProperty spritesData = serializedObject.FindProperty("spritesData"); + spritesData.objectReferenceValue = null; + + SerializedProperty normalGenerationMode = serializedObject.FindProperty("normalGenerationMode"); + normalGenerationMode.enumValueIndex = (int)tk2dSpriteCollection.NormalGenerationMode.None; + } + EditorGUILayout.PropertyField(skeletonJSON); EditorGUILayout.PropertyField(scale); diff --git a/spine-tk2d/Example/Example.unity b/spine-tk2d/Example/Example.unity index 984945f60b93952d0afa6e755eed86a4fdc27654..5c7df9b62574148f6f1343923dc48ad25e46cac8 100644 GIT binary patch delta 62 zcmbQy!?>b{QJR6lk%581O#?`90@(^cn!!ZRP|qmMaHF)839C0;qEJ?IuC@v_< zEJ-Z}aVBqM&Xmi{D`CjXFUn2KaZk-lElMoO%+K@9Pf2B90h%E`c_WMPWGNOUMv2L` zEb5GslkYRDGfGYFWl?672FmF$%1pk`s>~=mnVC(QQ4XxyicNq~9xSRbIiF2=@@7_% z$;;UI7?mb(Vbx+(2Fs{`)vLnQtARz;!RoiLLDXwb-pZ!Vs5SX6&}8k&jO@ycI$-q{ z?EH+nU{*A{0OOR&IqYfzy`u3C<9>f|Y4=@vj&Yvd{>_Wn9XTe;2$(PfJu%r|z!3mi CCQiKo delta 286 zcmbQDI6+aGfq{J$1B1W>1_lOBAPuA#7)CrXCdBBSEucWhFV+1UgbmB4b!VBIQMb*q9^ zsDX8>gLP{Fb*nRKP8MTVX4IN&1thgWIt9{l@)JuS*0KQor2`aHW}Gm2DZ84$ee*RF jU*3@NUK)Gqw06X&h|Raz9XTcoa9B>35ipq?BH#c3f0R(P