diff --git a/.gitignore b/.gitignore index 55bf694d7..72b73798b 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,15 @@ spine-unity/*.sln Assembly-*.csproj Assembly-*.pidb +spine-tk2d/Assets/Spine/spine-csharp +!spine-tk2d/Assets/Spine/spine-csharp/Place spine-csharp here.txt +spine-tk2d/ProjectSettings +spine-tk2d/Temp +spine-tk2d/Library +spine-tk2d/*.sln +spine-tk2d/Assets/TK2DROOT* +spine-tk2d/Assets/-tk2d* + spine-corona/spine-lua/ !spine-corona/spine-lua/Place spine-lua here.txt diff --git a/spine-tk2d/Assets/Spine.meta b/spine-tk2d/Assets/Spine.meta new file mode 100644 index 000000000..661958cff --- /dev/null +++ b/spine-tk2d/Assets/Spine.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 1fdd5b9e3e0974d40b1b149ec5a15662 +folderAsset: yes +DefaultImporter: + userData: diff --git a/spine-tk2d/Assets/Spine/Editor.meta b/spine-tk2d/Assets/Spine/Editor.meta new file mode 100644 index 000000000..18a2e4c7e --- /dev/null +++ b/spine-tk2d/Assets/Spine/Editor.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: ad07f9d157ce0a1468016aa5b6683e2a +folderAsset: yes +DefaultImporter: + userData: diff --git a/spine-tk2d/Assets/Spine/Editor/Menus.cs b/spine-tk2d/Assets/Spine/Editor/Menus.cs new file mode 100644 index 000000000..0811a2151 --- /dev/null +++ b/spine-tk2d/Assets/Spine/Editor/Menus.cs @@ -0,0 +1,61 @@ +using System; +using System.IO; +using UnityEditor; +using UnityEngine; +using Spine; + +public class Menus { + [MenuItem("Assets/Create/Spine SkeletonData")] + static public void CreateSkeletonData () { + CreateAsset("New SkeletonData"); + } + + static private void CreateAsset (String path) where T : ScriptableObject { + try { + path = Path.GetDirectoryName(AssetDatabase.GetAssetPath(Selection.activeObject)) + "/" + path; + } catch (Exception) { + path = "Assets/" + path; + } + ScriptableObject asset = ScriptableObject.CreateInstance(); + AssetDatabase.CreateAsset(asset, path + ".asset"); + AssetDatabase.SaveAssets(); + EditorUtility.FocusProjectWindow(); + Selection.activeObject = asset; + } + + [MenuItem("GameObject/Create Other/Spine SkeletonComponent")] + static public void CreateSkeletonComponentGameObject () { + GameObject gameObject = new GameObject("New SkeletonComponent", typeof(SkeletonComponent)); + EditorUtility.FocusProjectWindow(); + Selection.activeObject = gameObject; + } + + [MenuItem("GameObject/Create Other/Spine SkeletonAnimation")] + static public void CreateSkeletonAnimationGameObject () { + GameObject gameObject = new GameObject("New SkeletonAnimation", typeof(SkeletonAnimation)); + 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/Code/tk2dSpineSkeleton.cs.meta b/spine-tk2d/Assets/Spine/Editor/Menus.cs.meta similarity index 78% rename from spine-tk2d/Code/tk2dSpineSkeleton.cs.meta rename to spine-tk2d/Assets/Spine/Editor/Menus.cs.meta index fa2a45a66..f524d5648 100644 --- a/spine-tk2d/Code/tk2dSpineSkeleton.cs.meta +++ b/spine-tk2d/Assets/Spine/Editor/Menus.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b2ccbecf56104874f886da59557ff3e4 +guid: 1907c00e57244fd4c8ff68eee5a58761 MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/spine-tk2d/Assets/Spine/Editor/SkeletonAnimationInspector.cs b/spine-tk2d/Assets/Spine/Editor/SkeletonAnimationInspector.cs new file mode 100644 index 000000000..6524c387f --- /dev/null +++ b/spine-tk2d/Assets/Spine/Editor/SkeletonAnimationInspector.cs @@ -0,0 +1,117 @@ +/******************************************************************************* + * 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 System; +using UnityEditor; +using UnityEngine; + +[CustomEditor(typeof(SkeletonAnimation))] +public class SkeletonAnimationInspector : Editor { + private SerializedProperty skeletonDataAsset, animationName, loop, useAnimationName, initialSkinName, timeScale; + + void OnEnable () { + skeletonDataAsset = serializedObject.FindProperty("skeletonDataAsset"); + animationName = serializedObject.FindProperty("animationName"); + loop = serializedObject.FindProperty("loop"); + useAnimationName = serializedObject.FindProperty("useAnimationName"); + initialSkinName = serializedObject.FindProperty("initialSkinName"); + timeScale = serializedObject.FindProperty("timeScale"); + } + + override public void OnInspectorGUI () { + serializedObject.Update(); + SkeletonComponent component = (SkeletonComponent)target; + + EditorGUIUtility.LookLikeInspector(); + EditorGUILayout.PropertyField(skeletonDataAsset); + + if (component.skeleton != null) { + // Initial skin name. + String[] skins = new String[component.skeleton.Data.Skins.Count + 1]; + int skinIndex = 0; + for (int i = 0; i < skins.Length - 1; i++) { + String name = component.skeleton.Data.Skins[i].Name; + skins[i] = name; + if (name == initialSkinName.stringValue) + skinIndex = i; + } + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Initial Skin"); + EditorGUIUtility.LookLikeControls(); + skinIndex = EditorGUILayout.Popup(skinIndex, skins); + EditorGUIUtility.LookLikeInspector(); + EditorGUILayout.EndHorizontal(); + + initialSkinName.stringValue = skinIndex == 0 ? null : skins[skinIndex]; + + // Animation name. + String[] animations = new String[component.skeleton.Data.Animations.Count + 2]; + animations[0] = ""; + animations[1] = ""; + int animationIndex = useAnimationName.boolValue ? 1 : 0; + for (int i = 0; i < animations.Length - 2; i++) { + String name = component.skeleton.Data.Animations[i].Name; + animations[i + 2] = name; + if (name == animationName.stringValue) + animationIndex = i + 2; + } + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Animation"); + EditorGUIUtility.LookLikeControls(); + animationIndex = EditorGUILayout.Popup(animationIndex, animations); + EditorGUIUtility.LookLikeInspector(); + EditorGUILayout.EndHorizontal(); + + if (animationIndex == 0) { + animationName.stringValue = null; + useAnimationName.boolValue = false; + } else if (animationIndex == 1) { + animationName.stringValue = null; + useAnimationName.boolValue = true; + } else { + animationName.stringValue = animations[animationIndex]; + useAnimationName.boolValue = true; + } + } + + // Animation loop. + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Loop"); + loop.boolValue = EditorGUILayout.Toggle(loop.boolValue); + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.PropertyField(timeScale); + + if (serializedObject.ApplyModifiedProperties() || + (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") + ) { + if (!Application.isPlaying) { + component.Clear(); + component.Update(); + } + } + } +} diff --git a/spine-tk2d/Code/tk2dSpineAnimation.cs.meta b/spine-tk2d/Assets/Spine/Editor/SkeletonAnimationInspector.cs.meta similarity index 78% rename from spine-tk2d/Code/tk2dSpineAnimation.cs.meta rename to spine-tk2d/Assets/Spine/Editor/SkeletonAnimationInspector.cs.meta index 8ee863adb..890c139f8 100644 --- a/spine-tk2d/Code/tk2dSpineAnimation.cs.meta +++ b/spine-tk2d/Assets/Spine/Editor/SkeletonAnimationInspector.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c36a835202febaa4ba99b918635b1920 +guid: a21294688dd7a7349a5ca17241fb40e0 MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/spine-tk2d/Assets/Spine/Editor/SkeletonComponentInspector.cs b/spine-tk2d/Assets/Spine/Editor/SkeletonComponentInspector.cs new file mode 100644 index 000000000..cb23a1546 --- /dev/null +++ b/spine-tk2d/Assets/Spine/Editor/SkeletonComponentInspector.cs @@ -0,0 +1,78 @@ +/******************************************************************************* + * 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 System; +using UnityEditor; +using UnityEngine; + +[CustomEditor(typeof(SkeletonComponent))] +public class SkeletonComponentInspector : Editor { + private SerializedProperty skeletonDataAsset, initialSkinName, timeScale; + + void OnEnable () { + skeletonDataAsset = serializedObject.FindProperty("skeletonDataAsset"); + initialSkinName = serializedObject.FindProperty("initialSkinName"); + timeScale = serializedObject.FindProperty("timeScale"); + } + + override public void OnInspectorGUI () { + serializedObject.Update(); + SkeletonComponent component = (SkeletonComponent)target; + + EditorGUIUtility.LookLikeInspector(); + EditorGUILayout.PropertyField(skeletonDataAsset); + + if (component.skeleton != null) { + // Initial skin name. + String[] skins = new String[component.skeleton.Data.Skins.Count + 1]; + int skinIndex = 0; + for (int i = 0; i < skins.Length - 1; i++) { + String name = component.skeleton.Data.Skins[i].Name; + skins[i] = name; + if (name == initialSkinName.stringValue) + skinIndex = i; + } + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Initial Skin"); + EditorGUIUtility.LookLikeControls(); + skinIndex = EditorGUILayout.Popup(skinIndex, skins); + EditorGUIUtility.LookLikeInspector(); + EditorGUILayout.EndHorizontal(); + + initialSkinName.stringValue = skinIndex == 0 ? null : skins[skinIndex]; + } + + EditorGUILayout.PropertyField(timeScale); + + if (serializedObject.ApplyModifiedProperties() || + (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") + ) { + if (!Application.isPlaying) { + component.Clear(); + component.Update(); + } + } + } +} diff --git a/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs.meta b/spine-tk2d/Assets/Spine/Editor/SkeletonComponentInspector.cs.meta similarity index 78% rename from spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs.meta rename to spine-tk2d/Assets/Spine/Editor/SkeletonComponentInspector.cs.meta index ef43eb95e..59915bafb 100644 --- a/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs.meta +++ b/spine-tk2d/Assets/Spine/Editor/SkeletonComponentInspector.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c62fe2307a465b14793b8fdde54fdbe4 +guid: dbb89dadcac8d6b48869aeb81b0ae88f MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs b/spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs new file mode 100644 index 000000000..15ad75fc4 --- /dev/null +++ b/spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs @@ -0,0 +1,101 @@ +/******************************************************************************* + * 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 System; +using UnityEditor; +using UnityEngine; +using Spine; + +[CustomEditor(typeof(SkeletonDataAsset))] +public class SkeletonDataAssetInspector : Editor { + private SerializedProperty spriteCollection, skeletonJSON, scale, fromAnimation, toAnimation, duration; + private bool showAnimationStateData = true; + + void OnEnable () { + spriteCollection = serializedObject.FindProperty("spriteCollection"); + skeletonJSON = serializedObject.FindProperty("skeletonJSON"); + scale = serializedObject.FindProperty("scale"); + fromAnimation = serializedObject.FindProperty("fromAnimation"); + toAnimation = serializedObject.FindProperty("toAnimation"); + duration = serializedObject.FindProperty("duration"); + } + + override public void OnInspectorGUI () { + serializedObject.Update(); + SkeletonDataAsset asset = (SkeletonDataAsset)target; + + EditorGUIUtility.LookLikeInspector(); + + tk2dSpriteCollection sprites = EditorGUILayout.ObjectField("Sprite Collection", asset.spriteCollection, typeof(tk2dSpriteCollection), false) as tk2dSpriteCollection; + if (sprites != null) + spriteCollection.objectReferenceValue = sprites.spriteCollection; + + EditorGUILayout.PropertyField(skeletonJSON); + EditorGUILayout.PropertyField(scale); + + SkeletonData skeletonData = asset.GetSkeletonData(true); + if (skeletonData != null) { + showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data"); + if (showAnimationStateData) { + // Animation names. + String[] animations = new String[skeletonData.Animations.Count]; + for (int i = 0; i < animations.Length; i++) + animations[i] = skeletonData.Animations[i].Name; + + for (int i = 0; i < fromAnimation.arraySize; i++) { + SerializedProperty from = fromAnimation.GetArrayElementAtIndex(i); + SerializedProperty to = toAnimation.GetArrayElementAtIndex(i); + SerializedProperty durationProp = duration.GetArrayElementAtIndex(i); + EditorGUILayout.BeginHorizontal(); + from.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)]; + to.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)]; + durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue); + if (GUILayout.Button("Delete")) { + duration.DeleteArrayElementAtIndex(i); + toAnimation.DeleteArrayElementAtIndex(i); + fromAnimation.DeleteArrayElementAtIndex(i); + } + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.Space(); + if (GUILayout.Button("Add Mix")) { + duration.arraySize++; + toAnimation.arraySize++; + fromAnimation.arraySize++; + } + EditorGUILayout.Space(); + EditorGUILayout.EndHorizontal(); + } + } + + if (!Application.isPlaying) { + if (serializedObject.ApplyModifiedProperties() || + (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") + ) { + asset.Clear(); + } + } + } +} diff --git a/spine-tk2d/Code/tk2dSpineAttachmentLoader.cs.meta b/spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs.meta similarity index 78% rename from spine-tk2d/Code/tk2dSpineAttachmentLoader.cs.meta rename to spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs.meta index 75b7cc390..e7eaac24c 100644 --- a/spine-tk2d/Code/tk2dSpineAttachmentLoader.cs.meta +++ b/spine-tk2d/Assets/Spine/Editor/SkeletonDataAssetInspector.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9b8ea7c2b29e5814eb0b4b692b828869 +guid: cffb121e3cd80644d84c585b9c7448e8 MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/spine-tk2d/Assets/Spine/SkeletonAnimation.cs b/spine-tk2d/Assets/Spine/SkeletonAnimation.cs new file mode 100644 index 000000000..3caf76866 --- /dev/null +++ b/spine-tk2d/Assets/Spine/SkeletonAnimation.cs @@ -0,0 +1,66 @@ +/******************************************************************************* + * 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 System; +using System.IO; +using System.Collections.Generic; +using UnityEngine; +using Spine; + +/** Extends SkeletonComponent to apply an animation. */ +[ExecuteInEditMode, RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] +public class SkeletonAnimation : SkeletonComponent { + public bool useAnimationName; + public String animationName; + public bool loop; + public Spine.AnimationState state; + + override public void Initialize () { + base.Initialize(); // Call overridden method to initialize the skeleton. + + state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData()); + } + + override public void UpdateSkeleton () { + if (useAnimationName) { + // Keep AnimationState in sync with animationName and loop fields. + if (animationName == null || animationName.Length == 0) { + if (state.Animation != null) + state.ClearAnimation(); + } else if (state.Animation == null || animationName != state.Animation.Name) { + Spine.Animation animation = skeleton.Data.FindAnimation(animationName); + if (animation != null) + state.SetAnimation(animation, loop); + } + state.Loop = loop; + } + + // Apply the animation. + state.Update(Time.deltaTime * timeScale); + state.Apply(skeleton); + + // Call overridden method to call skeleton Update and UpdateWorldTransform. + base.UpdateSkeleton(); + } +} diff --git a/spine-tk2d/Assets/Spine/SkeletonAnimation.cs.meta b/spine-tk2d/Assets/Spine/SkeletonAnimation.cs.meta new file mode 100644 index 000000000..4c8681a72 --- /dev/null +++ b/spine-tk2d/Assets/Spine/SkeletonAnimation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 41133952e6d5fe04ca82a24ed4c02990 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/spine-tk2d/Assets/Spine/SkeletonComponent.cs b/spine-tk2d/Assets/Spine/SkeletonComponent.cs new file mode 100644 index 000000000..2ab63c07d --- /dev/null +++ b/spine-tk2d/Assets/Spine/SkeletonComponent.cs @@ -0,0 +1,252 @@ +/******************************************************************************* + * 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 System; +using System.IO; +using System.Collections.Generic; +using UnityEngine; +using Spine; + +/** Renders a skeleton. Extend to apply animations, get bones and manipulate them, etc. */ +[ExecuteInEditMode, RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))] +public class SkeletonComponent : MonoBehaviour { + public SkeletonDataAsset skeletonDataAsset; + public Skeleton skeleton; + public String initialSkinName; + public float timeScale = 1; + private Mesh mesh; + private int lastVertexCount; + private Vector3[] vertices; + private Color32[] colors; + private Vector2[] uvs; + private float[] vertexPositions = new float[8]; + private List submeshMaterials = new List(); + private List submeshIndexes = new List(); + private Material[] sharedMaterials = new Material[0]; + + public virtual void Clear () { + GetComponent().mesh = null; + DestroyImmediate(mesh); + mesh = null; + renderer.sharedMaterial = null; + skeleton = null; + } + + public virtual void Initialize () { + mesh = new Mesh(); + GetComponent().mesh = mesh; + mesh.name = "Skeleton Mesh"; + mesh.hideFlags = HideFlags.HideAndDontSave; + mesh.MarkDynamic(); + + // BOZO + //renderer.sharedMaterial = skeletonDataAsset.atlasAsset.material; + + vertices = new Vector3[0]; + + skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData(false)); + + if (initialSkinName != null && initialSkinName.Length > 0) { + skeleton.SetSkin(initialSkinName); + skeleton.SetSlotsToSetupPose(); + } + } + + public virtual void UpdateSkeleton () { + skeleton.Update(Time.deltaTime * timeScale); + skeleton.UpdateWorldTransform(); + } + + public virtual void Update () { + SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(false); + // Clear fields if missing information to render. + if (skeletonDataAsset == null || skeletonData == null) { + Clear(); + return; + } + + // Initialize fields. + if (skeleton == null || skeleton.Data != skeletonData) + Initialize(); + + UpdateSkeleton(); + + // Count quads and submeshes. + int quadCount = 0, submeshQuadCount = 0; + Material lastMaterial = null; + submeshMaterials.Clear(); + List drawOrder = skeleton.DrawOrder; + for (int i = 0, n = drawOrder.Count; i < n; i++) { + RegionAttachment regionAttachment = drawOrder[i].Attachment as RegionAttachment; + if (regionAttachment == null) + continue; + + // Add submesh when material changes. + Material material = (Material)regionAttachment.RendererObject; + if (lastMaterial != material && lastMaterial != null) { + addSubmesh(lastMaterial, quadCount, submeshQuadCount, false); + submeshQuadCount = 0; + } + lastMaterial = material; + + quadCount++; + submeshQuadCount++; + } + addSubmesh(lastMaterial, quadCount, submeshQuadCount, false); + + // Set materials. + if (submeshMaterials.Count == sharedMaterials.Length) + submeshMaterials.CopyTo(sharedMaterials); + else + sharedMaterials = submeshMaterials.ToArray(); + renderer.sharedMaterials = sharedMaterials; + + // Ensure mesh data is the right size. + Mesh mesh = this.mesh; + Vector3[] vertices = this.vertices; + int vertexCount = quadCount * 4; + bool newTriangles = vertexCount > vertices.Length; + if (newTriangles) { + // Not enough vertices, increase size. + this.vertices = vertices = new Vector3[vertexCount]; + this.colors = new Color32[vertexCount]; + this.uvs = new Vector2[vertexCount]; + mesh.Clear(); + } else { + // Too many vertices, zero the extra. + Vector3 zero = new Vector3(0, 0, 0); + for (int i = vertexCount, n = lastVertexCount; i < n; i++) + vertices[i] = zero; + } + lastVertexCount = vertexCount; + + // Setup mesh. + float[] vertexPositions = this.vertexPositions; + Vector2[] uvs = this.uvs; + Color32[] colors = this.colors; + int vertexIndex = 0; + Color32 color = new Color32(); + for (int i = 0, n = drawOrder.Count; i < n; i++) { + Slot slot = drawOrder[i]; + RegionAttachment regionAttachment = slot.Attachment as RegionAttachment; + if (regionAttachment == null) + continue; + + regionAttachment.ComputeVertices(skeleton.X, skeleton.Y, slot.Bone, vertexPositions); + + vertices[vertexIndex] = new Vector3(vertexPositions[RegionAttachment.X1], vertexPositions[RegionAttachment.Y1], 0); + vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4], vertexPositions[RegionAttachment.Y4], 0); + vertices[vertexIndex + 2] = new Vector3(vertexPositions[RegionAttachment.X2], vertexPositions[RegionAttachment.Y2], 0); + vertices[vertexIndex + 3] = new Vector3(vertexPositions[RegionAttachment.X3], vertexPositions[RegionAttachment.Y3], 0); + + color.a = (byte)(skeleton.A * slot.A * 255); + color.r = (byte)(skeleton.R * slot.R * color.a); + color.g = (byte)(skeleton.G * slot.G * color.a); + color.b = (byte)(skeleton.B * slot.B * color.a); + colors[vertexIndex] = color; + colors[vertexIndex + 1] = color; + colors[vertexIndex + 2] = color; + colors[vertexIndex + 3] = color; + + float[] regionUVs = regionAttachment.UVs; + uvs[vertexIndex] = new Vector2(regionUVs[RegionAttachment.X1], regionUVs[RegionAttachment.Y1]); + uvs[vertexIndex + 1] = new Vector2(regionUVs[RegionAttachment.X4], regionUVs[RegionAttachment.Y4]); + uvs[vertexIndex + 2] = new Vector2(regionUVs[RegionAttachment.X2], regionUVs[RegionAttachment.Y2]); + uvs[vertexIndex + 3] = new Vector2(regionUVs[RegionAttachment.X3], regionUVs[RegionAttachment.Y3]); + + vertexIndex += 4; + } + mesh.vertices = vertices; + mesh.colors32 = colors; + mesh.uv = uvs; + mesh.subMeshCount = submeshMaterials.Count; + for (int i = 0; i < mesh.subMeshCount; ++i) + mesh.SetTriangles(submeshIndexes[i], i); + } + + /** Adds a material. Adds submesh indexes if existing indexes aren't sufficient. */ + private void addSubmesh (Material material, int endQuadCount, int submeshQuadCount, bool exact) { + int submeshIndex = submeshMaterials.Count; + submeshMaterials.Add(material); + + // Return if the existing submesh is big enough. + int indexCount = submeshQuadCount * 6; + if (submeshIndexes.Count > submeshIndex) { + if (exact) { + if (submeshIndexes[submeshIndex].Length == indexCount) + return; + } else { + if (submeshIndexes[submeshIndex].Length >= indexCount) + return; + } + } else + submeshIndexes.Add(null); + + int vertexIndex = (endQuadCount - submeshQuadCount) * 4; + int[] indexes = new int[indexCount]; + for (int i = 0; i < indexCount; i += 6, vertexIndex += 4) { + indexes[i] = vertexIndex; + indexes[i + 1] = vertexIndex + 2; + indexes[i + 2] = vertexIndex + 1; + indexes[i + 3] = vertexIndex + 2; + indexes[i + 4] = vertexIndex + 3; + indexes[i + 5] = vertexIndex + 1; + } + submeshIndexes[submeshIndex] = indexes; + } + + public virtual void OnEnable () { + Update(); + } + +#if UNITY_EDITOR + public virtual void OnDisable () { + Clear(); + } +#endif + + public virtual void Reset () { + Update(); + } + +#if UNITY_EDITOR + void OnDrawGizmos() { + Vector3 gizmosCenter = new Vector3(); + Vector3 gizmosSize = new Vector3(); + Vector3 min = new Vector3(float.MaxValue, float.MaxValue, 0f); + Vector3 max = new Vector3(float.MinValue, float.MinValue, 0f); + foreach (Vector3 vert in vertices) { + min = Vector3.Min (min, vert); + max = Vector3.Max (max, vert); + } + float width = max.x - min.x; + float height = max.y - min.y; + gizmosCenter = new Vector3(min.x + (width / 2f), min.y + (height / 2f), 0f); + gizmosSize = new Vector3(width, height, 1f); + Gizmos.color = Color.clear; + Gizmos.matrix = transform.localToWorldMatrix; + Gizmos.DrawCube(gizmosCenter, gizmosSize); + } +#endif +} diff --git a/spine-tk2d/Assets/Spine/SkeletonComponent.cs.meta b/spine-tk2d/Assets/Spine/SkeletonComponent.cs.meta new file mode 100644 index 000000000..c765d154a --- /dev/null +++ b/spine-tk2d/Assets/Spine/SkeletonComponent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9da572b571dc33444bd6622951ef62ba +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/spine-tk2d/Assets/Spine/SkeletonDataAsset.cs b/spine-tk2d/Assets/Spine/SkeletonDataAsset.cs new file mode 100644 index 000000000..e0a6b8caa --- /dev/null +++ b/spine-tk2d/Assets/Spine/SkeletonDataAsset.cs @@ -0,0 +1,90 @@ +/******************************************************************************* + * 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 System; +using System.IO; +using UnityEngine; +using Spine; + +public class SkeletonDataAsset : ScriptableObject { + public tk2dSpriteCollectionData spriteCollection; + public TextAsset skeletonJSON; + public float scale = 1; + public String[] fromAnimation; + public String[] toAnimation; + public float[] duration; + private SkeletonData skeletonData; + private AnimationStateData stateData; + + public void Clear () { + skeletonData = null; + stateData = null; + } + + public SkeletonData GetSkeletonData (bool quiet) { + if (spriteCollection == null) { + if (!quiet) + Debug.LogWarning("Sprite collection not set for skeleton data asset: " + name, this); + Clear(); + return null; + } + + if (skeletonJSON == null) { + if (!quiet) + Debug.LogWarning("Skeleton JSON file not set for skeleton data asset: " + name, this); + Clear(); + return null; + } + + if (skeletonData != null) + return skeletonData; + + SkeletonJson json = new SkeletonJson(new SpriteCollectionAttachmentLoader(spriteCollection)); + json.Scale = 1.0f / (spriteCollection.invOrthoSize * spriteCollection.halfTargetHeight) * scale; + + try { + skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text)); + } catch (Exception ex) { + Debug.Log("Error reading skeleton JSON file for skeleton data asset: " + name + "\n" + + ex.Message + "\n" + ex.StackTrace, this); + return null; + } + + stateData = new AnimationStateData(skeletonData); + for (int i = 0, n = fromAnimation.Length; i < n; i++) { + if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) + continue; + stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]); + } + + return skeletonData; + } + + public AnimationStateData GetAnimationStateData () { + if (stateData != null) + return stateData; + GetSkeletonData(false); + return stateData; + } +} diff --git a/spine-tk2d/Assets/Spine/SkeletonDataAsset.cs.meta b/spine-tk2d/Assets/Spine/SkeletonDataAsset.cs.meta new file mode 100644 index 000000000..1760b1a58 --- /dev/null +++ b/spine-tk2d/Assets/Spine/SkeletonDataAsset.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1bdfe79e336474848808de1467defd7f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/spine-tk2d/Code/tk2dSpineAttachmentLoader.cs b/spine-tk2d/Assets/Spine/SpriteCollectionAttachmentLoader.cs similarity index 65% rename from spine-tk2d/Code/tk2dSpineAttachmentLoader.cs rename to spine-tk2d/Assets/Spine/SpriteCollectionAttachmentLoader.cs index e0ce36c76..31ca3107d 100644 --- a/spine-tk2d/Code/tk2dSpineAttachmentLoader.cs +++ b/spine-tk2d/Assets/Spine/SpriteCollectionAttachmentLoader.cs @@ -4,26 +4,32 @@ using Spine; // TODO: handle TPackerCW flip mode (probably not swap uv horizontaly) -public class tk2dSpineAttachmentLoader : AttachmentLoader { +public class SpriteCollectionAttachmentLoader : AttachmentLoader { private tk2dSpriteCollectionData sprites; - public tk2dSpineAttachmentLoader(tk2dSpriteCollectionData sprites) { - if (sprites == null) throw new ArgumentNullException("sprites cannot be null."); + public SpriteCollectionAttachmentLoader (tk2dSpriteCollectionData sprites) { + if (sprites == null) + throw new ArgumentNullException("sprites cannot be null."); this.sprites = sprites; } - public Attachment NewAttachment(Skin skin, AttachmentType type, String name) { - if (type != AttachmentType.region) throw new Exception("Unknown attachment type: " + type); + public Attachment NewAttachment (Skin skin, AttachmentType type, String name) { + if (type != AttachmentType.region) + throw new Exception("Unknown attachment type: " + type); // Strip folder names. int index = name.LastIndexOfAny(new char[] {'/', '\\'}); - if (index != -1) name = name.Substring(index + 1); + if (index != -1) + name = name.Substring(index + 1); tk2dSpriteDefinition def = sprites.GetSpriteDefinition(name); - if (def == null) throw new Exception("Sprite not found in atlas: " + name + " (" + type + ")"); - if (def.complexGeometry) throw new NotImplementedException("Complex geometry is not supported: " + name + " (" + type + ")"); - if (def.flipped == tk2dSpriteDefinition.FlipMode.TPackerCW) throw new NotImplementedException("Only 2D Toolkit atlases are supported: " + name + " (" + type + ")"); + if (def == null) + throw new Exception("Sprite not found in atlas: " + name + " (" + type + ")"); + if (def.complexGeometry) + throw new NotImplementedException("Complex geometry is not supported: " + name + " (" + type + ")"); + if (def.flipped == tk2dSpriteDefinition.FlipMode.TPackerCW) + throw new NotImplementedException("Only 2D Toolkit atlases are supported: " + name + " (" + type + ")"); RegionAttachment attachment = new RegionAttachment(name); @@ -62,6 +68,8 @@ public class tk2dSpineAttachmentLoader : AttachmentLoader { float y1 = def.boundsData[0].y - def.boundsData[1].y / 2; attachment.RegionOffsetY = (int)((y1 - y0) / def.texelSize.y); + attachment.RendererObject = def.material; + return attachment; } } diff --git a/spine-tk2d/Assets/Spine/SpriteCollectionAttachmentLoader.cs.meta b/spine-tk2d/Assets/Spine/SpriteCollectionAttachmentLoader.cs.meta new file mode 100644 index 000000000..6cc8612ae --- /dev/null +++ b/spine-tk2d/Assets/Spine/SpriteCollectionAttachmentLoader.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ad5a031e905ab0469fe2e19ff1b94ee +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/spine-tk2d/Assets/Spine/spine-csharp.meta b/spine-tk2d/Assets/Spine/spine-csharp.meta new file mode 100644 index 000000000..ef59cc982 --- /dev/null +++ b/spine-tk2d/Assets/Spine/spine-csharp.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: afc6035066a4eb4478f706aa211ca644 +folderAsset: yes +DefaultImporter: + userData: diff --git a/spine-tk2d/Assets/examples.meta b/spine-tk2d/Assets/examples.meta new file mode 100644 index 000000000..914d7a476 --- /dev/null +++ b/spine-tk2d/Assets/examples.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: ddc30294e8bdeb0469c854ccf66824fc +folderAsset: yes +DefaultImporter: + userData: diff --git a/spine-tk2d/Assets/examples/spineboy.meta b/spine-tk2d/Assets/examples/spineboy.meta new file mode 100644 index 000000000..b24e382b6 --- /dev/null +++ b/spine-tk2d/Assets/examples/spineboy.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: aafe437f17003ec449c178c2c329d221 +folderAsset: yes +DefaultImporter: + userData: diff --git a/spine-tk2d/Example/Spineboy/Skeleton/SpineboySkeletonAsset.asset b/spine-tk2d/Assets/examples/spineboy/Spineboy SkeletonData.asset similarity index 63% rename from spine-tk2d/Example/Spineboy/Skeleton/SpineboySkeletonAsset.asset rename to spine-tk2d/Assets/examples/spineboy/Spineboy SkeletonData.asset index a68094f07..c75e70e8e 100644 Binary files a/spine-tk2d/Example/Spineboy/Skeleton/SpineboySkeletonAsset.asset and b/spine-tk2d/Assets/examples/spineboy/Spineboy SkeletonData.asset differ diff --git a/spine-tk2d/Example/Spineboy/Skeleton/SpineboySkeletonAsset.asset.meta b/spine-tk2d/Assets/examples/spineboy/Spineboy SkeletonData.asset.meta similarity index 100% rename from spine-tk2d/Example/Spineboy/Skeleton/SpineboySkeletonAsset.asset.meta rename to spine-tk2d/Assets/examples/spineboy/Spineboy SkeletonData.asset.meta diff --git a/spine-tk2d/Example/Scripts/tk2dSpineboy.cs b/spine-tk2d/Assets/examples/spineboy/Spineboy.cs similarity index 73% rename from spine-tk2d/Example/Scripts/tk2dSpineboy.cs rename to spine-tk2d/Assets/examples/spineboy/Spineboy.cs index 665e2b3c7..6892296a0 100644 --- a/spine-tk2d/Example/Scripts/tk2dSpineboy.cs +++ b/spine-tk2d/Assets/examples/spineboy/Spineboy.cs @@ -1,13 +1,11 @@ using UnityEngine; using System.Collections; -/* - */ -public class tk2dSpineboy : MonoBehaviour { - private tk2dSpineAnimation skeleton; +public class Spineboy : MonoBehaviour { + private SkeletonAnimation skeleton; void Start() { - skeleton = GetComponent(); + skeleton = GetComponent(); } void LateUpdate() { diff --git a/spine-tk2d/Example/Scripts/tk2dSpineboy.cs.meta b/spine-tk2d/Assets/examples/spineboy/Spineboy.cs.meta similarity index 100% rename from spine-tk2d/Example/Scripts/tk2dSpineboy.cs.meta rename to spine-tk2d/Assets/examples/spineboy/Spineboy.cs.meta diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data.meta b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data.meta similarity index 84% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data.meta rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data.meta index 5b0fbfc64..ee99d1479 100644 --- a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data.meta +++ b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data.meta @@ -1,4 +1,5 @@ fileFormatVersion: 2 guid: ecf18700fc84ae94ca3cfa6d301b50c0 +folderAsset: yes DefaultImporter: userData: diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.prefab b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/SpineboyAtlas.prefab similarity index 63% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.prefab rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/SpineboyAtlas.prefab index e1834654a..88ab821eb 100644 Binary files a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.prefab and b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/SpineboyAtlas.prefab differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.prefab.meta b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/SpineboyAtlas.prefab.meta similarity index 58% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.prefab.meta rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/SpineboyAtlas.prefab.meta index 3d0e83bf9..9fdbd2eaa 100644 --- a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.prefab.meta +++ b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/SpineboyAtlas.prefab.meta @@ -1,4 +1,4 @@ fileFormatVersion: 2 -guid: 75ba18a107160134091f702a9e446567 +guid: 4cd6560d5de81b240b7e7d9beaa3e2f0 NativeFormatImporter: userData: diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0 material.mat b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0 material.mat similarity index 98% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0 material.mat rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0 material.mat index 5bf47f106..32a5ab152 100644 Binary files a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0 material.mat and b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0 material.mat differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0 material.mat.meta b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0 material.mat.meta similarity index 100% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0 material.mat.meta rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0 material.mat.meta diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0.png b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0.png rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0.png diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0.png.meta b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0.png.meta rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0.png.meta index 3f20a8dd2..4ee935e25 100644 --- a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas0.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas0.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 1 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: -1 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1 material.mat b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1 material.mat new file mode 100644 index 000000000..9f3d6cf09 Binary files /dev/null and b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1 material.mat differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1 material.mat.meta b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1 material.mat.meta similarity index 100% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1 material.mat.meta rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1 material.mat.meta diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1.png b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1.png rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1.png diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1.png.meta b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1.png.meta rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1.png.meta index 67523de6a..8cd6a6ffb 100644 --- a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas1.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 1 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: -1 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2 material.mat b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2 material.mat new file mode 100644 index 000000000..fbfed7cb4 Binary files /dev/null and b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2 material.mat differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2 material.mat.meta b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2 material.mat.meta similarity index 100% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2 material.mat.meta rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2 material.mat.meta diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2.png b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2.png rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2.png diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2.png.meta b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2.png.meta rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2.png.meta index 43e935013..2e48d601a 100644 --- a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas Data/atlas2.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 1 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: -1 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas.prefab b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas.prefab new file mode 100644 index 000000000..f8db7b6d0 Binary files /dev/null and b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas.prefab differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas.prefab.meta b/spine-tk2d/Assets/examples/spineboy/SpineboyAtlas.prefab.meta similarity index 100% rename from spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas.prefab.meta rename to spine-tk2d/Assets/examples/spineboy/SpineboyAtlas.prefab.meta diff --git a/spine-tk2d/Assets/examples/spineboy/images.meta b/spine-tk2d/Assets/examples/spineboy/images.meta new file mode 100644 index 000000000..98831c7f8 --- /dev/null +++ b/spine-tk2d/Assets/examples/spineboy/images.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 59b6b8248068c5c48a322d8b794e27ba +folderAsset: yes +DefaultImporter: + userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/eyes-closed.png b/spine-tk2d/Assets/examples/spineboy/images/eyes-closed.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/eyes-closed.png rename to spine-tk2d/Assets/examples/spineboy/images/eyes-closed.png diff --git a/spine-tk2d/Example/Spineboy/Textures/eyes-closed.png.meta b/spine-tk2d/Assets/examples/spineboy/images/eyes-closed.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/eyes-closed.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/eyes-closed.png.meta index fd4fca291..6fe8f3bce 100644 --- a/spine-tk2d/Example/Spineboy/Textures/eyes-closed.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/eyes-closed.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/eyes.png b/spine-tk2d/Assets/examples/spineboy/images/eyes.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/eyes.png rename to spine-tk2d/Assets/examples/spineboy/images/eyes.png diff --git a/spine-tk2d/Example/Spineboy/Textures/eyes.png.meta b/spine-tk2d/Assets/examples/spineboy/images/eyes.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/eyes.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/eyes.png.meta index 3dde41aef..bb4ede519 100644 --- a/spine-tk2d/Example/Spineboy/Textures/eyes.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/eyes.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/head.png b/spine-tk2d/Assets/examples/spineboy/images/head.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/head.png rename to spine-tk2d/Assets/examples/spineboy/images/head.png diff --git a/spine-tk2d/Example/Spineboy/Textures/head.png.meta b/spine-tk2d/Assets/examples/spineboy/images/head.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/head.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/head.png.meta index 386aa883b..fc217a743 100644 --- a/spine-tk2d/Example/Spineboy/Textures/head.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/head.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/left-ankle.png b/spine-tk2d/Assets/examples/spineboy/images/left-ankle.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/left-ankle.png rename to spine-tk2d/Assets/examples/spineboy/images/left-ankle.png diff --git a/spine-tk2d/Example/Spineboy/Textures/left-ankle.png.meta b/spine-tk2d/Assets/examples/spineboy/images/left-ankle.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/left-ankle.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/left-ankle.png.meta index 264ef901c..997e1ba1e 100644 --- a/spine-tk2d/Example/Spineboy/Textures/left-ankle.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/left-ankle.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/left-arm.png b/spine-tk2d/Assets/examples/spineboy/images/left-arm.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/left-arm.png rename to spine-tk2d/Assets/examples/spineboy/images/left-arm.png diff --git a/spine-tk2d/Example/Spineboy/Textures/left-arm.png.meta b/spine-tk2d/Assets/examples/spineboy/images/left-arm.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/left-arm.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/left-arm.png.meta index 37f6ce2dd..daf5a1618 100644 --- a/spine-tk2d/Example/Spineboy/Textures/left-arm.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/left-arm.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/left-foot.png b/spine-tk2d/Assets/examples/spineboy/images/left-foot.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/left-foot.png rename to spine-tk2d/Assets/examples/spineboy/images/left-foot.png diff --git a/spine-tk2d/Example/Spineboy/Textures/left-foot.png.meta b/spine-tk2d/Assets/examples/spineboy/images/left-foot.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/left-foot.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/left-foot.png.meta index fb200da05..5777f4539 100644 --- a/spine-tk2d/Example/Spineboy/Textures/left-foot.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/left-foot.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/left-hand.png b/spine-tk2d/Assets/examples/spineboy/images/left-hand.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/left-hand.png rename to spine-tk2d/Assets/examples/spineboy/images/left-hand.png diff --git a/spine-tk2d/Example/Spineboy/Textures/left-hand.png.meta b/spine-tk2d/Assets/examples/spineboy/images/left-hand.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/left-hand.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/left-hand.png.meta index 33c2f709d..aaf18d5ce 100644 --- a/spine-tk2d/Example/Spineboy/Textures/left-hand.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/left-hand.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/left-lower-leg.png b/spine-tk2d/Assets/examples/spineboy/images/left-lower-leg.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/left-lower-leg.png rename to spine-tk2d/Assets/examples/spineboy/images/left-lower-leg.png diff --git a/spine-tk2d/Example/Spineboy/Textures/left-lower-leg.png.meta b/spine-tk2d/Assets/examples/spineboy/images/left-lower-leg.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/left-lower-leg.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/left-lower-leg.png.meta index 5c2c1e598..7eab399c5 100644 --- a/spine-tk2d/Example/Spineboy/Textures/left-lower-leg.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/left-lower-leg.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/left-pant-bottom.png b/spine-tk2d/Assets/examples/spineboy/images/left-pant-bottom.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/left-pant-bottom.png rename to spine-tk2d/Assets/examples/spineboy/images/left-pant-bottom.png diff --git a/spine-tk2d/Example/Spineboy/Textures/left-pant-bottom.png.meta b/spine-tk2d/Assets/examples/spineboy/images/left-pant-bottom.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/left-pant-bottom.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/left-pant-bottom.png.meta index 857b0f522..c29d1470e 100644 --- a/spine-tk2d/Example/Spineboy/Textures/left-pant-bottom.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/left-pant-bottom.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/left-shoulder.png b/spine-tk2d/Assets/examples/spineboy/images/left-shoulder.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/left-shoulder.png rename to spine-tk2d/Assets/examples/spineboy/images/left-shoulder.png diff --git a/spine-tk2d/Example/Spineboy/Textures/left-shoulder.png.meta b/spine-tk2d/Assets/examples/spineboy/images/left-shoulder.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/left-shoulder.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/left-shoulder.png.meta index c79eb6af8..cbb3f185c 100644 --- a/spine-tk2d/Example/Spineboy/Textures/left-shoulder.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/left-shoulder.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/left-upper-leg.png b/spine-tk2d/Assets/examples/spineboy/images/left-upper-leg.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/left-upper-leg.png rename to spine-tk2d/Assets/examples/spineboy/images/left-upper-leg.png diff --git a/spine-tk2d/Example/Spineboy/Textures/left-upper-leg.png.meta b/spine-tk2d/Assets/examples/spineboy/images/left-upper-leg.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/left-upper-leg.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/left-upper-leg.png.meta index 0bee98bfb..ec84d7195 100644 --- a/spine-tk2d/Example/Spineboy/Textures/left-upper-leg.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/left-upper-leg.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/neck.png b/spine-tk2d/Assets/examples/spineboy/images/neck.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/neck.png rename to spine-tk2d/Assets/examples/spineboy/images/neck.png diff --git a/spine-tk2d/Example/Spineboy/Textures/neck.png.meta b/spine-tk2d/Assets/examples/spineboy/images/neck.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/neck.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/neck.png.meta index b8d3e0cc8..125bb4f3b 100644 --- a/spine-tk2d/Example/Spineboy/Textures/neck.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/neck.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/pelvis.png b/spine-tk2d/Assets/examples/spineboy/images/pelvis.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/pelvis.png rename to spine-tk2d/Assets/examples/spineboy/images/pelvis.png diff --git a/spine-tk2d/Example/Spineboy/Textures/pelvis.png.meta b/spine-tk2d/Assets/examples/spineboy/images/pelvis.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/pelvis.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/pelvis.png.meta index f4266bf70..7982626cf 100644 --- a/spine-tk2d/Example/Spineboy/Textures/pelvis.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/pelvis.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/right-ankle.png b/spine-tk2d/Assets/examples/spineboy/images/right-ankle.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/right-ankle.png rename to spine-tk2d/Assets/examples/spineboy/images/right-ankle.png diff --git a/spine-tk2d/Example/Spineboy/Textures/right-ankle.png.meta b/spine-tk2d/Assets/examples/spineboy/images/right-ankle.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/right-ankle.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/right-ankle.png.meta index 4c1577599..f13270b26 100644 --- a/spine-tk2d/Example/Spineboy/Textures/right-ankle.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/right-ankle.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/right-arm.png b/spine-tk2d/Assets/examples/spineboy/images/right-arm.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/right-arm.png rename to spine-tk2d/Assets/examples/spineboy/images/right-arm.png diff --git a/spine-tk2d/Example/Spineboy/Textures/right-arm.png.meta b/spine-tk2d/Assets/examples/spineboy/images/right-arm.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/right-arm.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/right-arm.png.meta index 21ba8fb96..034b7f943 100644 --- a/spine-tk2d/Example/Spineboy/Textures/right-arm.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/right-arm.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/right-foot-idle.png b/spine-tk2d/Assets/examples/spineboy/images/right-foot-idle.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/right-foot-idle.png rename to spine-tk2d/Assets/examples/spineboy/images/right-foot-idle.png diff --git a/spine-tk2d/Example/Spineboy/Textures/right-foot-idle.png.meta b/spine-tk2d/Assets/examples/spineboy/images/right-foot-idle.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/right-foot-idle.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/right-foot-idle.png.meta index 0ee303589..c45fc8585 100644 --- a/spine-tk2d/Example/Spineboy/Textures/right-foot-idle.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/right-foot-idle.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/right-foot.png b/spine-tk2d/Assets/examples/spineboy/images/right-foot.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/right-foot.png rename to spine-tk2d/Assets/examples/spineboy/images/right-foot.png diff --git a/spine-tk2d/Example/Spineboy/Textures/right-foot.png.meta b/spine-tk2d/Assets/examples/spineboy/images/right-foot.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/right-foot.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/right-foot.png.meta index d07b7a3b8..666b78ed2 100644 --- a/spine-tk2d/Example/Spineboy/Textures/right-foot.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/right-foot.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/right-hand.png b/spine-tk2d/Assets/examples/spineboy/images/right-hand.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/right-hand.png rename to spine-tk2d/Assets/examples/spineboy/images/right-hand.png diff --git a/spine-tk2d/Example/Spineboy/Textures/right-hand.png.meta b/spine-tk2d/Assets/examples/spineboy/images/right-hand.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/right-hand.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/right-hand.png.meta index 67a5d6113..e8667eeec 100644 --- a/spine-tk2d/Example/Spineboy/Textures/right-hand.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/right-hand.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/right-lower-leg.png b/spine-tk2d/Assets/examples/spineboy/images/right-lower-leg.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/right-lower-leg.png rename to spine-tk2d/Assets/examples/spineboy/images/right-lower-leg.png diff --git a/spine-tk2d/Example/Spineboy/Textures/right-lower-leg.png.meta b/spine-tk2d/Assets/examples/spineboy/images/right-lower-leg.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/right-lower-leg.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/right-lower-leg.png.meta index 53b1a4222..359d35322 100644 --- a/spine-tk2d/Example/Spineboy/Textures/right-lower-leg.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/right-lower-leg.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/right-pant-bottom.png b/spine-tk2d/Assets/examples/spineboy/images/right-pant-bottom.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/right-pant-bottom.png rename to spine-tk2d/Assets/examples/spineboy/images/right-pant-bottom.png diff --git a/spine-tk2d/Example/Spineboy/Textures/right-pant-bottom.png.meta b/spine-tk2d/Assets/examples/spineboy/images/right-pant-bottom.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/right-pant-bottom.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/right-pant-bottom.png.meta index f0e6675ab..d1c6972b5 100644 --- a/spine-tk2d/Example/Spineboy/Textures/right-pant-bottom.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/right-pant-bottom.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/right-shoulder.png b/spine-tk2d/Assets/examples/spineboy/images/right-shoulder.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/right-shoulder.png rename to spine-tk2d/Assets/examples/spineboy/images/right-shoulder.png diff --git a/spine-tk2d/Example/Spineboy/Textures/right-shoulder.png.meta b/spine-tk2d/Assets/examples/spineboy/images/right-shoulder.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/right-shoulder.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/right-shoulder.png.meta index b089841b3..1fae0cd0d 100644 --- a/spine-tk2d/Example/Spineboy/Textures/right-shoulder.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/right-shoulder.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/right-upper-leg.png b/spine-tk2d/Assets/examples/spineboy/images/right-upper-leg.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/right-upper-leg.png rename to spine-tk2d/Assets/examples/spineboy/images/right-upper-leg.png diff --git a/spine-tk2d/Example/Spineboy/Textures/right-upper-leg.png.meta b/spine-tk2d/Assets/examples/spineboy/images/right-upper-leg.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/right-upper-leg.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/right-upper-leg.png.meta index aa2e90a94..55d66cb72 100644 --- a/spine-tk2d/Example/Spineboy/Textures/right-upper-leg.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/right-upper-leg.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Textures/torso.png b/spine-tk2d/Assets/examples/spineboy/images/torso.png similarity index 100% rename from spine-tk2d/Example/Spineboy/Textures/torso.png rename to spine-tk2d/Assets/examples/spineboy/images/torso.png diff --git a/spine-tk2d/Example/Spineboy/Textures/torso.png.meta b/spine-tk2d/Assets/examples/spineboy/images/torso.png.meta similarity index 96% rename from spine-tk2d/Example/Spineboy/Textures/torso.png.meta rename to spine-tk2d/Assets/examples/spineboy/images/torso.png.meta index 7aa019960..d36b4ff99 100644 --- a/spine-tk2d/Example/Spineboy/Textures/torso.png.meta +++ b/spine-tk2d/Assets/examples/spineboy/images/torso.png.meta @@ -30,6 +30,7 @@ TextureImporter: nPOTScale: 0 lightmap: 0 compressionQuality: 50 + alphaIsTransparency: 0 textureType: 5 buildTargetSettings: [] userData: diff --git a/spine-tk2d/Example/Spineboy/Skeleton/Spineboy.json.txt b/spine-tk2d/Assets/examples/spineboy/spineboy.json.txt similarity index 100% rename from spine-tk2d/Example/Spineboy/Skeleton/Spineboy.json.txt rename to spine-tk2d/Assets/examples/spineboy/spineboy.json.txt diff --git a/spine-tk2d/Example/Spineboy/Skeleton/Spineboy.json.txt.meta b/spine-tk2d/Assets/examples/spineboy/spineboy.json.txt.meta similarity index 100% rename from spine-tk2d/Example/Spineboy/Skeleton/Spineboy.json.txt.meta rename to spine-tk2d/Assets/examples/spineboy/spineboy.json.txt.meta diff --git a/spine-tk2d/Example/Example.unity b/spine-tk2d/Assets/examples/spineboy/spineboy.unity similarity index 75% rename from spine-tk2d/Example/Example.unity rename to spine-tk2d/Assets/examples/spineboy/spineboy.unity index bc7e18b13..eaedafe36 100644 Binary files a/spine-tk2d/Example/Example.unity and b/spine-tk2d/Assets/examples/spineboy/spineboy.unity differ diff --git a/spine-tk2d/Example/Example.unity.meta b/spine-tk2d/Assets/examples/spineboy/spineboy.unity.meta similarity index 56% rename from spine-tk2d/Example/Example.unity.meta rename to spine-tk2d/Assets/examples/spineboy/spineboy.unity.meta index bd083a187..89cd16f65 100644 --- a/spine-tk2d/Example/Example.unity.meta +++ b/spine-tk2d/Assets/examples/spineboy/spineboy.unity.meta @@ -1,4 +1,4 @@ fileFormatVersion: 2 -guid: a6669a1e8d1cb5c45b165fe92714942b +guid: 3e1554ca46e91194fb8d9ead0b21f6f7 DefaultImporter: userData: diff --git a/spine-tk2d/Code/tk2dSpineAnimation.cs b/spine-tk2d/Code/tk2dSpineAnimation.cs deleted file mode 100644 index f0639c4c6..000000000 --- a/spine-tk2d/Code/tk2dSpineAnimation.cs +++ /dev/null @@ -1,44 +0,0 @@ -using UnityEngine; -using Spine; - -// TODO: add events in animation component - -[RequireComponent(typeof(tk2dSpineSkeleton))] -public class tk2dSpineAnimation : MonoBehaviour { - - public string animationName; - public bool loop; - public float animationSpeed = 1; - public Spine.AnimationState state; - - private tk2dSpineSkeleton cachedSpineSkeleton; - - void Start () { - cachedSpineSkeleton = GetComponent(); - state = new Spine.AnimationState(cachedSpineSkeleton.skeletonDataAsset.GetAnimationStateData()); - } - - void Update () { - UpdateAnimation(); - } - - private void UpdateAnimation() { - // Check if we need to stop current animation - if (state.Animation != null && animationName == null) { - state.ClearAnimation(); - } - - // Check for different animation name or animation end - else if (state.Animation == null || animationName != state.Animation.Name) { - Spine.Animation animation = cachedSpineSkeleton.skeleton.Data.FindAnimation(animationName); - if (animation != null) state.SetAnimation(animation,loop); - } - - state.Loop = loop; - - // Update animation - cachedSpineSkeleton.skeleton.Update(Time.deltaTime * animationSpeed); - state.Update(Time.deltaTime * animationSpeed); - state.Apply(cachedSpineSkeleton.skeleton); - } -} diff --git a/spine-tk2d/Code/tk2dSpineSkeleton.cs b/spine-tk2d/Code/tk2dSpineSkeleton.cs deleted file mode 100644 index fb016aded..000000000 --- a/spine-tk2d/Code/tk2dSpineSkeleton.cs +++ /dev/null @@ -1,237 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; -using Spine; - -[ExecuteInEditMode] -[RequireComponent(typeof(MeshFilter))] -[RequireComponent(typeof(MeshRenderer))] -public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionForceBuild { - public tk2dSpineSkeletonDataAsset skeletonDataAsset; - public Skeleton skeleton; - - private Mesh mesh; - private Vector3[] vertices; - private Color32[] colors; - private Vector2[] uvs; - private int cachedQuadCount; - private float[] vertexPositions; - private List submeshMaterials = new List(); - private List submeshIndices = new List(); - - void Awake() { - vertexPositions = new float[8]; - submeshMaterials = new List(); - submeshIndices = new List(); - } - - void Start () { - Initialize(); - } - - void Update () { - SkeletonData skeletonData = skeletonDataAsset == null ? null : skeletonDataAsset.GetSkeletonData(); - if (skeletonData == null) { - Clear(); - return; - } - - if (skeleton == null || skeleton.Data != skeletonData) Initialize(); - - skeleton.UpdateWorldTransform(); - - UpdateCache(); - UpdateMesh(); - } - - private void Clear() { - GetComponent().mesh = null; - DestroyImmediate(mesh); - mesh = null; - - skeleton = null; - } - - private void Initialize() { - mesh = new Mesh(); - GetComponent().mesh = mesh; - mesh.name = "tk2dSkeleton Mesh"; - mesh.hideFlags = HideFlags.HideAndDontSave; - - if(skeletonDataAsset != null) { - skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData()); - } - } - - private void UpdateMesh() { - int quadIndex = 0; - int drawCount = skeleton.DrawOrder.Count; - - Color32 color = new Color32(); - for (int i = 0; i < drawCount; i++) { - Slot slot = skeleton.DrawOrder[i]; - Attachment attachment = slot.Attachment; - - if (attachment is RegionAttachment) { - RegionAttachment regionAttachment = attachment as RegionAttachment; - regionAttachment.ComputeVertices(skeleton.X, skeleton.Y, slot.Bone, vertexPositions); - - int vertexIndex = quadIndex * 4; - vertices[vertexIndex + 0] = new Vector3(vertexPositions[RegionAttachment.X1],vertexPositions[RegionAttachment.Y1],0); - vertices[vertexIndex + 1] = new Vector3(vertexPositions[RegionAttachment.X4],vertexPositions[RegionAttachment.Y4],0); - vertices[vertexIndex + 2] = new Vector3(vertexPositions[RegionAttachment.X2],vertexPositions[RegionAttachment.Y2],0); - vertices[vertexIndex + 3] = new Vector3(vertexPositions[RegionAttachment.X3],vertexPositions[RegionAttachment.Y3],0); - - float[] regionUVs = regionAttachment.UVs; - uvs[vertexIndex + 0] = new Vector2(regionUVs[RegionAttachment.X1],regionUVs[RegionAttachment.Y1]); - uvs[vertexIndex + 1] = new Vector2(regionUVs[RegionAttachment.X4],regionUVs[RegionAttachment.Y4]); - uvs[vertexIndex + 2] = new Vector2(regionUVs[RegionAttachment.X2],regionUVs[RegionAttachment.Y2]); - uvs[vertexIndex + 3] = new Vector2(regionUVs[RegionAttachment.X3],regionUVs[RegionAttachment.Y3]); - - color.a = (byte)(skeleton.A * slot.A * 255); - color.r = (byte)(skeleton.R * slot.R * color.a); - color.g = (byte)(skeleton.G * slot.G * color.a); - color.b = (byte)(skeleton.B * slot.B * color.a); - - colors[vertexIndex] = color; - colors[vertexIndex + 1] = color; - colors[vertexIndex + 2] = color; - colors[vertexIndex + 3] = color; - - quadIndex++; - } - } - - mesh.vertices = vertices; - mesh.colors32 = colors; - mesh.uv = uvs; - - if (skeletonDataAsset.normalGenerationMode != tk2dSpriteCollection.NormalGenerationMode.None) { - mesh.RecalculateNormals(); - - if (skeletonDataAsset.normalGenerationMode == tk2dSpriteCollection.NormalGenerationMode.NormalsAndTangents) { - Vector4[] tangents = new Vector4[mesh.normals.Length]; - for (int i = 0; i < tangents.Length; i++) { - tangents[i] = new Vector4(1, 0, 0, 1); - } - mesh.tangents = tangents; - } - } - -#if UNITY_EDITOR - UpdateEditorGizmo(); -#endif - } - - private void UpdateCache() { - int quadCount = 0; - int drawCount = skeleton.DrawOrder.Count; - - for (int i = 0; i < drawCount; i++) { - Attachment attachment = skeleton.DrawOrder[i].Attachment; - if (attachment is RegionAttachment) quadCount++; - } - -#if UNITY_EDITOR - if (mesh.subMeshCount == submeshIndices.Count) -#endif - if (quadCount == cachedQuadCount) return; - - cachedQuadCount = quadCount; - vertices = new Vector3[quadCount * 4]; - uvs = new Vector2[quadCount * 4]; - colors = new Color32[quadCount * 4]; - - UpdateSubmeshCache(); - - mesh.Clear(); - mesh.vertices = vertices; - mesh.colors32 = colors; - mesh.uv = uvs; - - mesh.subMeshCount = submeshIndices.Count; - for(int i = 0; i < mesh.subMeshCount; ++i) { - mesh.SetTriangles(submeshIndices[i],i); - } - } - - private void UpdateSubmeshCache() { - submeshIndices.Clear(); - submeshMaterials.Clear(); - - Material oldMaterial = null; - List currentSubmesh = new List(); - int quadIndex = 0; - - int drawCount = skeleton.DrawOrder.Count; - for (int i = 0; i < drawCount; i++) { - Attachment attachment = skeleton.DrawOrder[i].Attachment; - if (!(attachment is RegionAttachment)) continue; - Material currentMaterial = skeletonDataAsset.spritesData.GetSpriteDefinition(attachment.Name).material; - - if (oldMaterial == null) oldMaterial = currentMaterial; - - if (oldMaterial != currentMaterial) { - submeshIndices.Add(currentSubmesh.ToArray()); - submeshMaterials.Add(oldMaterial); - currentSubmesh.Clear(); - } - - int vertexIndex = quadIndex * 4; - - currentSubmesh.Add(vertexIndex); - currentSubmesh.Add(vertexIndex + 2); - currentSubmesh.Add(vertexIndex + 1); - currentSubmesh.Add(vertexIndex + 2); - currentSubmesh.Add(vertexIndex + 3); - currentSubmesh.Add(vertexIndex + 1); - - quadIndex++; - - oldMaterial = currentMaterial; - } - - submeshIndices.Add(currentSubmesh.ToArray()); - submeshMaterials.Add(oldMaterial); - - renderer.sharedMaterials = submeshMaterials.ToArray(); - } - - - public bool UsesSpriteCollection(tk2dSpriteCollectionData spriteCollection) { - return skeletonDataAsset.spritesData == spriteCollection; - } - - public void ForceBuild() { - skeletonDataAsset.ForceUpdate(); - skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData()); - - UpdateSubmeshCache(); - UpdateMesh(); - } - -#region Unity Editor -#if UNITY_EDITOR - Vector3 gizmosCenter = new Vector3(); - Vector3 gizmosSize = new Vector3(); - Vector3 min = new Vector3(float.MaxValue, float.MaxValue, 0f); - Vector3 max = new Vector3(float.MinValue, float.MinValue, 0f); - - void UpdateEditorGizmo() { - //determine the minimums and maximums - foreach (Vector3 vert in vertices) { - min = Vector3.Min(min, vert); - max = Vector3.Max(max, vert); - } - float width = max.x - min.x; - float height = max.y - min.y; - gizmosCenter = new Vector3(min.x + (width / 2f), min.y + (height / 2f), 0f); - gizmosSize = new Vector3(width, height, 1f); - } - void OnDrawGizmos() { - Gizmos.color = Color.clear; - Gizmos.matrix = transform.localToWorldMatrix; - Gizmos.DrawCube(gizmosCenter, gizmosSize); - } -#endif -#endregion -} diff --git a/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs b/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs deleted file mode 100644 index c6382f26c..000000000 --- a/spine-tk2d/Code/tk2dSpineSkeletonDataAsset.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.IO; -using UnityEngine; -using Spine; - -public class tk2dSpineSkeletonDataAsset : ScriptableObject { - public tk2dSpriteCollectionData spritesData; - public tk2dSpriteCollection.NormalGenerationMode normalGenerationMode = tk2dSpriteCollection.NormalGenerationMode.None; - - public TextAsset skeletonJSON; - - public string[] fromAnimation; - public string[] toAnimation; - public float[] duration; - - private SkeletonData skeletonData; - private AnimationStateData stateData; - - public SkeletonData GetSkeletonData() { - if (skeletonData != null) return skeletonData; - - MakeSkeletonAndAnimationData(); - return skeletonData; - } - - public AnimationStateData GetAnimationStateData () { - if (stateData != null) return stateData; - - MakeSkeletonAndAnimationData(); - return stateData; - } - - private void MakeSkeletonAndAnimationData() { - if (spritesData == null) { - Debug.LogWarning("Sprite collection not set for skeleton data asset: " + name,this); - return; - } - - if (skeletonJSON == null) { - Debug.LogWarning("Skeleton JSON file not set for skeleton data asset: " + name,this); - return; - } - - SkeletonJson json = new SkeletonJson(new tk2dSpineAttachmentLoader(spritesData)); - json.Scale = 1.0f / (spritesData.invOrthoSize * spritesData.halfTargetHeight); - - try { - skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text)); - } catch (Exception ex) { - Debug.Log("Error reading skeleton JSON file for skeleton data asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace,this); - return; - } - - stateData = new AnimationStateData(skeletonData); - for (int i = 0, n = fromAnimation.Length; i < n; i++) { - if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue; - stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]); - } - } - - public void ForceUpdate() { - MakeSkeletonAndAnimationData(); - } -} diff --git a/spine-tk2d/Editor/tk2dSpineMenus.cs b/spine-tk2d/Editor/tk2dSpineMenus.cs deleted file mode 100644 index 1c76b1f75..000000000 --- a/spine-tk2d/Editor/tk2dSpineMenus.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.IO; -using UnityEditor; -using UnityEngine; -using Spine; - -/* - */ -public class tk2dSpineMenus { - - /* - */ - [MenuItem("Assets/Create/tk2d/Spine Skeleton Data")] - static public void CreateSkeletonData() { - string path = ""; - try { - path = Path.GetDirectoryName(AssetDatabase.GetAssetPath(Selection.activeObject)) + "/"; - } catch (Exception) { - path = "Assets/"; - } - - ScriptableObject asset = ScriptableObject.CreateInstance(); - AssetDatabase.CreateAsset(asset,path + "New Spine Skeleton Data.asset"); - AssetDatabase.SaveAssets(); - EditorUtility.FocusProjectWindow(); - Selection.activeObject = asset; - } - - /* - */ - [MenuItem("GameObject/Create Other/tk2d/Spine Skeleton")] - static public void CreateSkeletonGameObject() { - GameObject gameObject = new GameObject("New tk2d Spine Skeleton",typeof(tk2dSpineSkeleton)); - EditorUtility.FocusProjectWindow(); - Selection.activeObject = gameObject; - } - - /* - */ - [MenuItem("GameObject/Create Other/tk2d/Spine Animated Skeleton")] - static public void CreateAnimatedSkeletonGameObject() { - GameObject gameObject = new GameObject("New tk2d Spine Animated Skeleton",typeof(tk2dSpineAnimation)); - EditorUtility.FocusProjectWindow(); - Selection.activeObject = gameObject; - } - - /* - */ - [MenuItem("Component/2D Toolkit/Spine Skeleton")] - static public void CreateSkeletonComponent() { - Selection.activeGameObject.AddComponent(typeof(tk2dSpineSkeleton)); - } - - /* - */ - [MenuItem("Component/2d Toolkit/Spine Skeleton",true)] - static public bool ValidateCreateSkeletonComponent() { - return Selection.activeGameObject != null && Selection.activeGameObject.GetComponent(typeof(tk2dSpineSkeleton)) == null; - } - - /* - */ - [MenuItem("Component/2D Toolkit/Spine Animation")] - static public void CreateAnimationComponent() { - Selection.activeGameObject.AddComponent(typeof(tk2dSpineAnimation)); - } - - /* - */ - [MenuItem("Component/2d Toolkit/Spine Animation",true)] - static public bool ValidateCreateAnimationComponent() { - return Selection.activeGameObject != null && Selection.activeGameObject.GetComponent(typeof(tk2dSpineAnimation)) == null; - } -} diff --git a/spine-tk2d/Editor/tk2dSpineMenus.cs.meta b/spine-tk2d/Editor/tk2dSpineMenus.cs.meta deleted file mode 100644 index b87f858f6..000000000 --- a/spine-tk2d/Editor/tk2dSpineMenus.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5673189c5c1030b4783c8945f5a5f52e -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs b/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs deleted file mode 100644 index b04e839bf..000000000 --- a/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; -using Spine; - -/* - */ -[CustomEditor(typeof(tk2dSpineSkeletonDataAsset))] -public class tk2dSpineSkeletonDataAssetInspector : Editor { - - /* - */ - private SerializedProperty skeletonJSON; - private SerializedProperty fromAnimation; - private SerializedProperty toAnimation; - private SerializedProperty duration; - private bool showAnimationStateData = true; - - private tk2dSpriteCollection sprites; - - /* - */ - void OnEnable () { - - 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"); - fromAnimation = serializedObject.FindProperty("fromAnimation"); - toAnimation = serializedObject.FindProperty("toAnimation"); - duration = serializedObject.FindProperty("duration"); - } - - /* - */ - public override void OnInspectorGUI () { - serializedObject.Update(); - - tk2dSpineSkeletonDataAsset asset = target as tk2dSpineSkeletonDataAsset; - - EditorGUIUtility.LookLikeInspector(); - 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); - - SkeletonData skeletonData = asset.GetSkeletonData(); - if(skeletonData != null) { - showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData,"Animation State Data"); - if(showAnimationStateData) { - - String[] animations = new String[skeletonData.Animations.Count]; - for (int i = 0; i < animations.Length; i++) { - animations[i] = skeletonData.Animations[i].Name; - } - - for(int i = 0; i < fromAnimation.arraySize; i++) { - SerializedProperty from = fromAnimation.GetArrayElementAtIndex(i); - SerializedProperty to = toAnimation.GetArrayElementAtIndex(i); - SerializedProperty durationProp = duration.GetArrayElementAtIndex(i); - - EditorGUILayout.BeginHorizontal(); - - from.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations,from.stringValue),0),animations)]; - to.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations,to.stringValue),0),animations)]; - durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue); - - if(GUILayout.Button("Delete")) { - duration.DeleteArrayElementAtIndex(i); - toAnimation.DeleteArrayElementAtIndex(i); - fromAnimation.DeleteArrayElementAtIndex(i); - } - - EditorGUILayout.EndHorizontal(); - } - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.Space(); - - if(GUILayout.Button("Add Mix")) { - duration.arraySize++; - toAnimation.arraySize++; - fromAnimation.arraySize++; - } - - EditorGUILayout.Space(); - EditorGUILayout.EndHorizontal(); - } - } - - serializedObject.ApplyModifiedProperties(); - } -} diff --git a/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs.meta b/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs.meta deleted file mode 100644 index d9414a9cf..000000000 --- a/spine-tk2d/Editor/tk2dSpineSkeletonDataAssetInspector.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7d6409f1851f307478265bb32705931c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/spine-tk2d/Example/Scripts.meta b/spine-tk2d/Example/Scripts.meta deleted file mode 100644 index e71894526..000000000 --- a/spine-tk2d/Example/Scripts.meta +++ /dev/null @@ -1,4 +0,0 @@ -fileFormatVersion: 2 -guid: 0d6ddec953cd68340ad934b7dbc49aee -DefaultImporter: - userData: diff --git a/spine-tk2d/Example/Spineboy.meta b/spine-tk2d/Example/Spineboy.meta deleted file mode 100644 index 579741202..000000000 --- a/spine-tk2d/Example/Spineboy.meta +++ /dev/null @@ -1,4 +0,0 @@ -fileFormatVersion: 2 -guid: ffc1cb83c8d59e94e8f56a1656ea21f4 -DefaultImporter: - userData: diff --git a/spine-tk2d/Example/Spineboy/Atlas.meta b/spine-tk2d/Example/Spineboy/Atlas.meta deleted file mode 100644 index ca1eb4036..000000000 --- a/spine-tk2d/Example/Spineboy/Atlas.meta +++ /dev/null @@ -1,4 +0,0 @@ -fileFormatVersion: 2 -guid: fbf5933c952a61e418970dfb8a22a9c5 -DefaultImporter: - userData: diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas material.mat b/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas material.mat deleted file mode 100644 index 0292fdc62..000000000 Binary files a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas material.mat and /dev/null differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas material.mat.meta b/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas material.mat.meta deleted file mode 100644 index c88980aac..000000000 --- a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas material.mat.meta +++ /dev/null @@ -1,4 +0,0 @@ -fileFormatVersion: 2 -guid: 4179f68f1f074f6419e77a5ce3326360 -NativeFormatImporter: - userData: diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.png b/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.png deleted file mode 100644 index 0de4fa319..000000000 Binary files a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.png and /dev/null differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.png.meta b/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.png.meta deleted file mode 100644 index d9f913d31..000000000 --- a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlas.png.meta +++ /dev/null @@ -1,35 +0,0 @@ -fileFormatVersion: 2 -guid: 87b566031e1e98a4ca10753473e6ab43 -TextureImporter: - serializedVersion: 2 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - linearTexture: 0 - correctGamma: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: .25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 0 - seamlessCubemap: 0 - textureFormat: -1 - maxTextureSize: 1024 - textureSettings: - filterMode: -1 - aniso: -1 - mipBias: -1 - wrapMode: -1 - nPOTScale: 1 - lightmap: 0 - compressionQuality: 50 - textureType: -1 - buildTargetSettings: [] - userData: diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlasData.prefab b/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlasData.prefab deleted file mode 100644 index dafc39234..000000000 Binary files a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlasData.prefab and /dev/null differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlasData.prefab.meta b/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlasData.prefab.meta deleted file mode 100644 index 009804a9b..000000000 --- a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/SpineboyAtlasData.prefab.meta +++ /dev/null @@ -1,4 +0,0 @@ -fileFormatVersion: 2 -guid: 51da69e827bd6824f9f747e9726b91be -NativeFormatImporter: - userData: diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1 material.mat b/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1 material.mat deleted file mode 100644 index 1bf3f5860..000000000 Binary files a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas1 material.mat and /dev/null differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2 material.mat b/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2 material.mat deleted file mode 100644 index 94240ae85..000000000 Binary files a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas Data/atlas2 material.mat and /dev/null differ diff --git a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas.prefab b/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas.prefab deleted file mode 100644 index 98e0624e3..000000000 Binary files a/spine-tk2d/Example/Spineboy/Atlas/SpineboyAtlas.prefab and /dev/null differ diff --git a/spine-tk2d/Example/Spineboy/Skeleton.meta b/spine-tk2d/Example/Spineboy/Skeleton.meta deleted file mode 100644 index e2af3c822..000000000 --- a/spine-tk2d/Example/Spineboy/Skeleton.meta +++ /dev/null @@ -1,4 +0,0 @@ -fileFormatVersion: 2 -guid: 1bbae6252278b4f4797821285fca644d -DefaultImporter: - userData: diff --git a/spine-tk2d/Example/Spineboy/Textures.meta b/spine-tk2d/Example/Spineboy/Textures.meta deleted file mode 100644 index d89c257db..000000000 --- a/spine-tk2d/Example/Spineboy/Textures.meta +++ /dev/null @@ -1,4 +0,0 @@ -fileFormatVersion: 2 -guid: 440ce1c2387029f48a05c43573aedc8c -DefaultImporter: - userData: diff --git a/spine-tk2d/README.md b/spine-tk2d/README.md index b8a9154a8..e77b44875 100644 --- a/spine-tk2d/README.md +++ b/spine-tk2d/README.md @@ -1,19 +1,18 @@ -The Spine runtime for Unity with 2d Toolkit comes with an example project which has "spineboy" walking. When clicked, he jumps and the transition to/from walking/jumping is blended smoothly. Use the instructions below. +The Spine runtime for Unity with 2D Toolkit comes with an example project which has "spineboy" walking. When clicked, he jumps and the transition to/from walking/jumping is blended smoothly. [Setup Video](http://www.youtube.com/watch?v=dnQbS9ap-i8) # Requirements -1. Latest 2d toolkit imported in your project -1. Latest Spine C# runtime +1. Unity 4.2+ +1. Latest 2D Toolkit -# Usage +# Instructions -1. Drag spine-csharp into your project -1. Drag spine-tk2d into your project -1. Open spine-tk2d/Example/Example.scene +1. Copy `spine-csharp/src` to `spine-unity-tk2d/Assets/Spine/spine-csharp`. +1. Open the `Assets/examples/spineboy/spineboy.unity` scene. +1. Import 2D Toolkit into your project. # Notes - Atlas images should use premultiplied alpha. -- All skeleton game objects should use Skeleton.shader