diff --git a/examples/raptor/export/raptor.atlas b/examples/raptor/export/raptor.atlas index 11728a52d..7e62f7e95 100644 --- a/examples/raptor/export/raptor.atlas +++ b/examples/raptor/export/raptor.atlas @@ -1,279 +1,251 @@ raptor.png -size: 1024,1024 +size: 2048,1024 format: RGBA8888 filter: Linear,Linear repeat: none back_arm - rotate: true - xy: 140, 191 - size: 46, 29 - orig: 46, 29 + rotate: false + xy: 1041, 93 + size: 91, 57 + orig: 91, 57 offset: 0, 0 index: -1 back_bracer - rotate: true - xy: 167, 317 - size: 39, 28 - orig: 39, 28 + rotate: false + xy: 942, 2 + size: 77, 55 + orig: 77, 55 offset: 0, 0 index: -1 back_hand rotate: false - xy: 167, 358 - size: 36, 34 - orig: 36, 34 + xy: 1973, 620 + size: 72, 68 + orig: 72, 68 offset: 0, 0 index: -1 back_knee rotate: false - xy: 299, 478 - size: 49, 67 - orig: 49, 67 + xy: 843, 28 + size: 97, 134 + orig: 97, 134 offset: 0, 0 index: -1 back_thigh - rotate: true - xy: 167, 437 - size: 39, 24 - orig: 39, 24 - offset: 0, 0 - index: -1 -eyes_closed - rotate: true - xy: 2, 2 - size: 47, 45 - orig: 47, 45 + rotate: false + xy: 1041, 44 + size: 78, 47 + orig: 78, 47 offset: 0, 0 index: -1 eyes_open - rotate: true - xy: 49, 2 - size: 47, 45 - orig: 47, 45 - offset: 0, 0 - index: -1 -eyes_surprised - rotate: true - xy: 96, 2 - size: 47, 45 - orig: 47, 45 + rotate: false + xy: 1506, 92 + size: 93, 89 + orig: 93, 89 offset: 0, 0 index: -1 front_arm rotate: false - xy: 419, 544 - size: 48, 30 - orig: 48, 30 + xy: 458, 13 + size: 96, 60 + orig: 96, 60 offset: 0, 0 index: -1 front_bracer rotate: false - xy: 880, 695 - size: 41, 29 - orig: 41, 29 + xy: 1134, 92 + size: 81, 58 + orig: 81, 58 offset: 0, 0 index: -1 front_hand - rotate: true - xy: 167, 394 - size: 41, 38 - orig: 41, 38 + rotate: false + xy: 1513, 187 + size: 82, 75 + orig: 82, 75 offset: 0, 0 index: -1 front_open_hand rotate: false - xy: 880, 726 - size: 43, 44 - orig: 43, 44 + xy: 1513, 264 + size: 86, 87 + orig: 86, 87 offset: 0, 0 index: -1 front_thigh rotate: false - xy: 360, 545 - size: 57, 29 - orig: 57, 29 + xy: 342, 15 + size: 114, 58 + orig: 114, 58 offset: 0, 0 index: -1 gun rotate: false - xy: 785, 774 - size: 107, 103 - orig: 107, 103 + xy: 1603, 278 + size: 213, 206 + orig: 213, 206 offset: 0, 0 index: -1 gun_nohand rotate: false - xy: 614, 703 - size: 105, 102 - orig: 105, 102 + xy: 1818, 281 + size: 210, 203 + orig: 210, 203 offset: 0, 0 index: -1 head rotate: false - xy: 2, 137 - size: 136, 149 - orig: 136, 149 + xy: 977, 152 + size: 271, 298 + orig: 271, 298 offset: 0, 0 index: -1 lower_leg - rotate: true - xy: 780, 699 - size: 73, 98 - orig: 73, 98 - offset: 0, 0 - index: -1 -mouth_grind rotate: false - xy: 469, 544 - size: 47, 30 - orig: 47, 30 - offset: 0, 0 - index: -1 -mouth_oooo - rotate: true - xy: 894, 772 - size: 105, 30 - orig: 105, 30 + xy: 1765, 81 + size: 146, 195 + orig: 146, 195 offset: 0, 0 index: -1 mouth_smile - rotate: true - xy: 140, 239 - size: 47, 30 - orig: 47, 30 + rotate: false + xy: 556, 14 + size: 93, 59 + orig: 93, 59 offset: 0, 0 index: -1 neck - rotate: true - xy: 538, 577 - size: 18, 21 - orig: 18, 21 + rotate: false + xy: 1935, 647 + size: 36, 41 + orig: 36, 41 offset: 0, 0 index: -1 raptor_arm_back rotate: false - xy: 940, 936 - size: 82, 86 - orig: 82, 86 + xy: 1250, 9 + size: 163, 172 + orig: 163, 172 offset: 0, 0 index: -1 raptor_body rotate: false - xy: 2, 737 - size: 610, 285 - orig: 610, 285 + xy: 2, 452 + size: 1219, 570 + orig: 1219, 570 offset: 0, 0 index: -1 raptor_front_arm - rotate: true - xy: 195, 464 - size: 81, 102 - orig: 81, 102 + rotate: false + xy: 1601, 73 + size: 162, 203 + orig: 162, 203 offset: 0, 0 index: -1 raptor_front_leg rotate: false - xy: 2, 478 - size: 191, 257 - orig: 191, 257 + xy: 1223, 508 + size: 382, 514 + orig: 382, 514 offset: 0, 0 index: -1 raptor_hindleg_back rotate: false - xy: 614, 807 - size: 169, 215 - orig: 169, 215 + xy: 2, 21 + size: 338, 429 + orig: 338, 429 offset: 0, 0 index: -1 raptor_horn rotate: false - xy: 360, 655 - size: 182, 80 - orig: 182, 80 + xy: 1607, 486 + size: 363, 159 + orig: 363, 159 offset: 0, 0 index: -1 raptor_horn_back rotate: false - xy: 360, 576 - size: 176, 77 - orig: 176, 77 + xy: 1250, 353 + size: 351, 153 + orig: 351, 153 offset: 0, 0 index: -1 raptor_jaw rotate: false - xy: 785, 879 - size: 153, 143 - orig: 153, 143 + xy: 670, 164 + size: 305, 286 + orig: 305, 286 offset: 0, 0 index: -1 raptor_saddle_noshadow rotate: false - xy: 2, 288 - size: 163, 188 - orig: 163, 188 + xy: 1607, 647 + size: 326, 375 + orig: 326, 375 offset: 0, 0 index: -1 raptor_saddle_strap_front rotate: false - xy: 721, 710 - size: 57, 95 - orig: 57, 95 + xy: 1913, 90 + size: 114, 189 + orig: 114, 189 offset: 0, 0 index: -1 raptor_saddle_strap_rear - rotate: true - xy: 940, 880 - size: 54, 74 - orig: 54, 74 + rotate: false + xy: 1935, 690 + size: 108, 148 + orig: 108, 148 offset: 0, 0 index: -1 raptor_saddle_w_shadow rotate: false - xy: 195, 547 - size: 163, 188 - orig: 163, 188 + xy: 342, 75 + size: 326, 375 + orig: 326, 375 offset: 0, 0 index: -1 raptor_tongue - rotate: true - xy: 544, 649 - size: 86, 64 - orig: 86, 64 + rotate: false + xy: 670, 34 + size: 171, 128 + orig: 171, 128 offset: 0, 0 index: -1 stirrup_back - rotate: true - xy: 140, 145 - size: 44, 35 - orig: 44, 35 + rotate: false + xy: 1415, 10 + size: 87, 69 + orig: 87, 69 offset: 0, 0 index: -1 stirrup_front rotate: false - xy: 538, 597 - size: 45, 50 - orig: 45, 50 + xy: 1415, 81 + size: 89, 100 + orig: 89, 100 offset: 0, 0 index: -1 stirrup_strap rotate: false - xy: 350, 497 - size: 49, 46 - orig: 49, 46 + xy: 942, 59 + size: 97, 91 + orig: 97, 91 offset: 0, 0 index: -1 torso - rotate: true - xy: 610, 647 - size: 54, 91 - orig: 54, 91 + rotate: false + xy: 1935, 840 + size: 108, 182 + orig: 108, 182 offset: 0, 0 index: -1 visor rotate: false - xy: 2, 51 - size: 131, 84 - orig: 131, 84 + xy: 1250, 183 + size: 261, 168 + orig: 261, 168 offset: 0, 0 index: -1 diff --git a/examples/raptor/export/raptor.png b/examples/raptor/export/raptor.png index 503d1c446..458cfe4c4 100644 Binary files a/examples/raptor/export/raptor.png and b/examples/raptor/export/raptor.png differ diff --git a/examples/tank/export/tank.atlas b/examples/tank/export/tank.atlas index 115f09479..7ffbee4e8 100644 --- a/examples/tank/export/tank.atlas +++ b/examples/tank/export/tank.atlas @@ -1,125 +1,125 @@ tank.png -size: 1024,512 +size: 2048,1024 format: RGBA8888 filter: Linear,Linear repeat: none antenna - rotate: true - xy: 650, 346 - size: 11, 152 - orig: 11, 152 + rotate: false + xy: 1411, 191 + size: 22, 303 + orig: 22, 303 offset: 0, 0 index: -1 cannon rotate: false - xy: 2, 49 - size: 466, 29 - orig: 466, 29 + xy: 2, 75 + size: 931, 58 + orig: 931, 58 offset: 0, 0 index: -1 cannonConnector - rotate: true - xy: 843, 231 - size: 56, 68 - orig: 56, 68 + rotate: false + xy: 1289, 359 + size: 112, 135 + orig: 112, 135 offset: 0, 0 index: -1 guntower rotate: false - xy: 650, 359 - size: 365, 145 - orig: 365, 145 + xy: 1295, 689 + size: 730, 289 + orig: 730, 289 offset: 0, 0 index: -1 machinegun rotate: false - xy: 2, 18 - size: 166, 29 - orig: 166, 29 + xy: 2, 16 + size: 331, 57 + orig: 331, 57 offset: 0, 0 index: -1 machinegun-mount - rotate: true - xy: 647, 193 - size: 36, 48 - orig: 36, 48 + rotate: false + xy: 1952, 591 + size: 72, 96 + orig: 72, 96 offset: 0, 0 index: -1 rock rotate: false - xy: 470, 50 - size: 126, 28 - orig: 126, 28 + xy: 935, 78 + size: 252, 55 + orig: 252, 55 offset: 0, 0 index: -1 tankBottom rotate: false - xy: 2, 193 - size: 643, 138 - orig: 643, 138 + xy: 2, 359 + size: 1285, 276 + orig: 1285, 276 offset: 0, 0 index: -1 tankBottom-shadow rotate: false - xy: 2, 333 - size: 646, 171 - orig: 646, 171 + xy: 2, 637 + size: 1291, 341 + orig: 1291, 341 offset: 0, 0 index: -1 tankTop rotate: false - xy: 2, 80 - size: 704, 111 - orig: 704, 111 + xy: 2, 135 + size: 1407, 222 + orig: 1407, 222 offset: 0, 0 index: -1 tread rotate: false - xy: 647, 231 - size: 48, 15 - orig: 48, 15 + xy: 1189, 103 + size: 96, 30 + orig: 96, 30 offset: 0, 0 index: -1 tread-inside rotate: false - xy: 2, 2 - size: 13, 14 - orig: 13, 14 + xy: 1676, 521 + size: 25, 28 + orig: 25, 28 offset: 0, 0 index: -1 wheel-big rotate: false - xy: 650, 248 - size: 96, 96 - orig: 96, 96 + xy: 1295, 496 + size: 191, 191 + orig: 191, 191 offset: 0, 0 index: -1 wheel-big-overlay rotate: false - xy: 748, 251 - size: 93, 93 - orig: 93, 93 + xy: 1488, 501 + size: 186, 186 + orig: 186, 186 offset: 0, 0 index: -1 wheel-mid rotate: false - xy: 843, 289 - size: 68, 68 - orig: 68, 68 + xy: 1676, 551 + size: 136, 136 + orig: 136, 136 offset: 0, 0 index: -1 wheel-mid-overlay rotate: false - xy: 913, 289 - size: 68, 68 - orig: 68, 68 + xy: 1814, 551 + size: 136, 136 + orig: 136, 136 offset: 0, 0 index: -1 wheel-small rotate: false - xy: 913, 251 - size: 36, 36 - orig: 36, 36 + xy: 335, 2 + size: 71, 71 + orig: 71, 71 offset: 0, 0 index: -1 diff --git a/examples/tank/export/tank.png b/examples/tank/export/tank.png index 71e402d65..0d4705f70 100644 Binary files a/examples/tank/export/tank.png and b/examples/tank/export/tank.png differ diff --git a/spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs b/spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs index 58ac0fce0..3f5e68bd3 100644 --- a/spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs +++ b/spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs @@ -31,9 +31,13 @@ using UnityEditor; using UnityEngine; -namespace Spine.Unity.Editor { +namespace Spine.Unity.Editor { + + using Editor = UnityEditor.Editor; + using Event = UnityEngine.Event; + [CustomEditor(typeof(BoneFollower)), CanEditMultipleObjects] - public class BoneFollowerInspector : UnityEditor.Editor { + public class BoneFollowerInspector : Editor { SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation, followLocalScale, followSkeletonFlip; BoneFollower targetBoneFollower; bool needsReset; @@ -121,7 +125,7 @@ namespace Spine.Unity.Editor { return; } - if (needsReset && UnityEngine.Event.current.type == EventType.Layout) { + if (needsReset && Event.current.type == EventType.Layout) { targetBoneFollower.Initialize(); targetBoneFollower.LateUpdate(); needsReset = false; @@ -171,7 +175,7 @@ namespace Spine.Unity.Editor { } } - var current = UnityEngine.Event.current; + var current = Event.current; bool wasUndo = (current.type == EventType.ValidateCommand && current.commandName == "UndoRedoPerformed"); if (wasUndo) targetBoneFollower.Initialize(); diff --git a/spine-unity/Assets/spine-unity/Editor/SkeletonAnimationInspector.cs b/spine-unity/Assets/spine-unity/Editor/SkeletonAnimationInspector.cs index 02bae7c69..fddfadfb8 100644 --- a/spine-unity/Assets/spine-unity/Editor/SkeletonAnimationInspector.cs +++ b/spine-unity/Assets/spine-unity/Editor/SkeletonAnimationInspector.cs @@ -61,7 +61,11 @@ namespace Spine.Unity.Editor { EditorGUILayout.Space(); if (!sameData) { + #if UNITY_5_3_OR_NEWER EditorGUILayout.DelayedTextField(animationName); + #else + animationName.stringValue = EditorGUILayout.TextField(animationName.displayName, animationName.stringValue); + #endif } else { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(animationName); diff --git a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs index 1f1b0f4f6..8b65d0a4c 100644 --- a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs +++ b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs @@ -1225,7 +1225,7 @@ namespace Spine.Unity.Editor { } // Version warning - { + if (isSpineData) { string runtimeVersion = compatibleVersions[0][0] + "." + compatibleVersions[0][1]; if (string.IsNullOrEmpty(rawVersion)) { diff --git a/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshedMeshGenerator.cs b/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshedMeshGenerator.cs index 664e8ab3c..4edaccaf8 100644 --- a/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshedMeshGenerator.cs +++ b/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshedMeshGenerator.cs @@ -35,7 +35,7 @@ namespace Spine.Unity.MeshGeneration { /// /// Arrays submeshed mesh generator. /// - public class ArraysSubmeshedMeshGenerator : ArraysMeshGenerator, ISubmeshedMeshGenerator { + public class ArraysSubmeshedMeshGenerator : ArraysMeshGenerator, ISubmeshedMeshGenerator, System.IDisposable { readonly List separators = new List(); public List Separators { get { return this.separators; } } @@ -49,6 +49,11 @@ namespace Spine.Unity.MeshGeneration { readonly ExposedList submeshBuffers = new ExposedList(); Material[] sharedMaterials = new Material[0]; + public void Dispose () { + doubleBufferedSmartMesh.GetNext().Dispose(); + doubleBufferedSmartMesh.GetNext().Dispose(); + } + public SubmeshedMeshInstruction GenerateInstruction (Skeleton skeleton) { if (skeleton == null) throw new System.ArgumentNullException("skeleton"); @@ -242,11 +247,21 @@ namespace Spine.Unity.MeshGeneration { #region Types // A SmartMesh is a Mesh (with submeshes) that knows what attachments and instructions were used to generate it. - class SmartMesh { + class SmartMesh : System.IDisposable { public readonly Mesh mesh = SpineMesh.NewMesh(); readonly ExposedList attachmentsUsed = new ExposedList(); readonly ExposedList instructionsUsed = new ExposedList(); + public void Dispose () { + if (mesh != null) { + if (Application.isEditor && !Application.isPlaying) { + UnityEngine.Object.DestroyImmediate(mesh); + } else { + UnityEngine.Object.Destroy(mesh); + } + } + } + public void Set (Vector3[] verts, Vector2[] uvs, Color32[] colors, SubmeshedMeshInstruction instruction) { mesh.vertices = verts; mesh.uv = uvs; diff --git a/spine-unity/Assets/spine-unity/SkeletonRenderer.cs b/spine-unity/Assets/spine-unity/SkeletonRenderer.cs index 880efc106..80e0de1c8 100644 --- a/spine-unity/Assets/spine-unity/SkeletonRenderer.cs +++ b/spine-unity/Assets/spine-unity/SkeletonRenderer.cs @@ -32,6 +32,7 @@ #define SPINE_OPTIONAL_MATERIALOVERRIDE #define SPINE_OPTIONAL_NORMALS #define SPINE_OPTIONAL_SOLVETANGENTS +//#define SPINE_OPTIONAL_FRONTFACING using System; using System.Collections.Generic; @@ -165,6 +166,13 @@ namespace Spine.Unity { ClearState(); } + void OnDestroy () { + if (doubleBufferedMesh == null) return; + doubleBufferedMesh.GetNext().Dispose(); + doubleBufferedMesh.GetNext().Dispose(); + doubleBufferedMesh = null; + } + protected virtual void ClearState () { meshFilter.sharedMesh = null; currentInstructions.Clear(); @@ -622,10 +630,24 @@ namespace Spine.Unity { } ///This is a Mesh that also stores the instructions SkeletonRenderer generated for it. - public class SmartMesh { + public class SmartMesh : System.IDisposable { public Mesh mesh = Spine.Unity.SpineMesh.NewMesh(); public SmartMesh.Instruction instructionUsed = new SmartMesh.Instruction(); + public void Dispose () { + if (mesh != null) { + #if UNITY_EDITOR + if (Application.isEditor && !Application.isPlaying) + UnityEngine.Object.DestroyImmediate(mesh); + else + UnityEngine.Object.Destroy(mesh); + #else + UnityEngine.Object.Destroy(mesh); + #endif + } + mesh = null; + } + public class Instruction { public bool immutableTriangles; public int vertexCount = -1;