From c2a79c43eda1f4f7d562c79389d942e92ea66c84 Mon Sep 17 00:00:00 2001 From: Yonsh Date: Sat, 15 Jun 2013 13:17:12 +0900 Subject: [PATCH 1/5] Fix: Unable to select in editor when flipped http://www.esotericsoftware.com/forum/viewtopic.php?f=3&t=823 --- .../Assets/Plugins/Spine/SkeletonComponent.cs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs index 46d904a33..0f4bd00f3 100644 --- a/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs +++ b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs @@ -43,6 +43,11 @@ public class SkeletonComponent : MonoBehaviour { private int[] triangles; private float[] vertexPositions = new float[8]; +#if UNITY_EDITOR + Vector3 gizmosCenter = new Vector3(); + Vector3 gizmosSize = new Vector3(); +#endif + public virtual void Clear () { GetComponent().mesh = null; DestroyImmediate(mesh); @@ -132,6 +137,9 @@ public class SkeletonComponent : MonoBehaviour { float[] vertexPositions = this.vertexPositions; int vertexIndex = 0; Color32 color = new Color32(); +#if UNITY_EDITOR + Vector3 min = new Vector3(float.MaxValue, float.MaxValue, 0), max = new Vector3(float.MinValue, float.MinValue, 0); +#endif for (int i = 0, n = drawOrder.Count; i < n; i++) { Slot slot = drawOrder[i]; RegionAttachment regionAttachment = slot.Attachment as RegionAttachment; @@ -143,6 +151,16 @@ public class SkeletonComponent : MonoBehaviour { 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); +#if UNITY_EDITOR + min = Vector3.Min(min, vertices[vertexIndex + 0]); + min = Vector3.Min(min, vertices[vertexIndex + 1]); + min = Vector3.Min(min, vertices[vertexIndex + 2]); + min = Vector3.Min(min, vertices[vertexIndex + 3]); + max = Vector3.Max(max, vertices[vertexIndex + 0]); + max = Vector3.Max(max, vertices[vertexIndex + 1]); + max = Vector3.Max(max, vertices[vertexIndex + 2]); + max = Vector3.Max(max, vertices[vertexIndex + 3]); +#endif color.a = (byte)(skeleton.A * slot.A * 255); color.r = (byte)(skeleton.R * slot.R * color.a); @@ -165,8 +183,21 @@ public class SkeletonComponent : MonoBehaviour { mesh.colors32 = colors; mesh.uv = uvs; if (newTriangles) mesh.triangles = triangles; +#if UNITY_EDITOR + float width = max.x - min.x, height = max.y - min.y; + gizmosCenter = new Vector3(min.x + width / 2, min.y + height / 2, 0); + gizmosSize = new Vector3(Mathf.Abs(width), Mathf.Abs(height), 1); +#endif } +#if UNITY_EDITOR + void OnDrawGizmos() { + Gizmos.color = Color.clear; + Gizmos.matrix = transform.localToWorldMatrix; + Gizmos.DrawCube(gizmosCenter, gizmosSize); + } +#endif + public virtual void OnEnable () { Update(); } From 4603b7eed3bf57af25ff195d807a2bc117435446 Mon Sep 17 00:00:00 2001 From: Yonsh Date: Sat, 15 Jun 2013 13:21:45 +0900 Subject: [PATCH 2/5] Fix: Unable to select in editor when flipped http://www.esotericsoftware.com/forum/viewtopic.php?f=3&t=823 --- spine-tk2d/Code/tk2dSpineSkeleton.cs | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spine-tk2d/Code/tk2dSpineSkeleton.cs b/spine-tk2d/Code/tk2dSpineSkeleton.cs index 4fe3c23ae..221258aa5 100644 --- a/spine-tk2d/Code/tk2dSpineSkeleton.cs +++ b/spine-tk2d/Code/tk2dSpineSkeleton.cs @@ -24,6 +24,11 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor private int[] triangles; private int cachedQuadCount; private float[] vertexPositions; + +#if UNITY_EDITOR + Vector3 gizmosCenter = new Vector3(); + Vector3 gizmosSize = new Vector3(); +#endif void Awake() { vertexPositions = new float[8]; @@ -73,6 +78,10 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor int quadIndex = 0; int drawCount = skeleton.DrawOrder.Count; Color currentColor = new Color(); + +#if UNITY_EDITOR + Vector3 min = new Vector3(float.MaxValue, float.MaxValue, 0), max = new Vector3(float.MinValue, float.MinValue, 0); +#endif for (int i = 0; i < drawCount; i++) { Slot slot = skeleton.DrawOrder[i]; @@ -114,8 +123,23 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor triangles[index + 5] = vertexIndex + 1; quadIndex++; +#if UNITY_EDITOR + min = Vector3.Min(min, vertices[vertexIndex + 0]); + min = Vector3.Min(min, vertices[vertexIndex + 1]); + min = Vector3.Min(min, vertices[vertexIndex + 2]); + min = Vector3.Min(min, vertices[vertexIndex + 3]); + max = Vector3.Max(max, vertices[vertexIndex + 0]); + max = Vector3.Max(max, vertices[vertexIndex + 1]); + max = Vector3.Max(max, vertices[vertexIndex + 2]); + max = Vector3.Max(max, vertices[vertexIndex + 3]); +#endif } } +#if UNITY_EDITOR + float width = max.x - min.x, height = max.y - min.y; + gizmosCenter = new Vector3(min.x + width / 2, min.y + height / 2, 0); + gizmosSize = new Vector3(Mathf.Abs(width), Mathf.Abs(height), 1); +#endif mesh.Clear(); @@ -138,6 +162,14 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor renderer.sharedMaterial = skeletonDataAsset.spritesData.inst.materials[0]; } + +#if UNITY_EDITOR + void OnDrawGizmos() { + Gizmos.color = Color.clear; + Gizmos.matrix = transform.localToWorldMatrix; + Gizmos.DrawCube(gizmosCenter, gizmosSize); + } +#endif private void UpdateCache() { int quadCount = 0; From f44e8aad50271a461ab7bb1bacba9c80cc12e9cc Mon Sep 17 00:00:00 2001 From: Yonsh Date: Sat, 15 Jun 2013 16:53:35 +0800 Subject: [PATCH 3/5] Change to pharan's recommendation --- .../Assets/Plugins/Spine/SkeletonComponent.cs | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs index 0f4bd00f3..565996c45 100644 --- a/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs +++ b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs @@ -43,11 +43,6 @@ public class SkeletonComponent : MonoBehaviour { private int[] triangles; private float[] vertexPositions = new float[8]; -#if UNITY_EDITOR - Vector3 gizmosCenter = new Vector3(); - Vector3 gizmosSize = new Vector3(); -#endif - public virtual void Clear () { GetComponent().mesh = null; DestroyImmediate(mesh); @@ -137,9 +132,6 @@ public class SkeletonComponent : MonoBehaviour { float[] vertexPositions = this.vertexPositions; int vertexIndex = 0; Color32 color = new Color32(); -#if UNITY_EDITOR - Vector3 min = new Vector3(float.MaxValue, float.MaxValue, 0), max = new Vector3(float.MinValue, float.MinValue, 0); -#endif for (int i = 0, n = drawOrder.Count; i < n; i++) { Slot slot = drawOrder[i]; RegionAttachment regionAttachment = slot.Attachment as RegionAttachment; @@ -151,16 +143,6 @@ public class SkeletonComponent : MonoBehaviour { 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); -#if UNITY_EDITOR - min = Vector3.Min(min, vertices[vertexIndex + 0]); - min = Vector3.Min(min, vertices[vertexIndex + 1]); - min = Vector3.Min(min, vertices[vertexIndex + 2]); - min = Vector3.Min(min, vertices[vertexIndex + 3]); - max = Vector3.Max(max, vertices[vertexIndex + 0]); - max = Vector3.Max(max, vertices[vertexIndex + 1]); - max = Vector3.Max(max, vertices[vertexIndex + 2]); - max = Vector3.Max(max, vertices[vertexIndex + 3]); -#endif color.a = (byte)(skeleton.A * slot.A * 255); color.r = (byte)(skeleton.R * slot.R * color.a); @@ -184,20 +166,10 @@ public class SkeletonComponent : MonoBehaviour { mesh.uv = uvs; if (newTriangles) mesh.triangles = triangles; #if UNITY_EDITOR - float width = max.x - min.x, height = max.y - min.y; - gizmosCenter = new Vector3(min.x + width / 2, min.y + height / 2, 0); - gizmosSize = new Vector3(Mathf.Abs(width), Mathf.Abs(height), 1); + UpdateEditorGizmo(); #endif } -#if UNITY_EDITOR - void OnDrawGizmos() { - Gizmos.color = Color.clear; - Gizmos.matrix = transform.localToWorldMatrix; - Gizmos.DrawCube(gizmosCenter, gizmosSize); - } -#endif - public virtual void OnEnable () { Update(); } @@ -210,4 +182,30 @@ public class SkeletonComponent : MonoBehaviour { public virtual void Reset () { Update(); } + +#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 } From 8851f3919fd4fe9534e04a6a878850edcfa3fe13 Mon Sep 17 00:00:00 2001 From: Yonsh Date: Sat, 15 Jun 2013 16:57:24 +0800 Subject: [PATCH 4/5] Change to pharan's recommendation --- spine-tk2d/Code/tk2dSpineSkeleton.cs | 59 +++++++++++++--------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/spine-tk2d/Code/tk2dSpineSkeleton.cs b/spine-tk2d/Code/tk2dSpineSkeleton.cs index 221258aa5..e1ec7a91d 100644 --- a/spine-tk2d/Code/tk2dSpineSkeleton.cs +++ b/spine-tk2d/Code/tk2dSpineSkeleton.cs @@ -24,11 +24,6 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor private int[] triangles; private int cachedQuadCount; private float[] vertexPositions; - -#if UNITY_EDITOR - Vector3 gizmosCenter = new Vector3(); - Vector3 gizmosSize = new Vector3(); -#endif void Awake() { vertexPositions = new float[8]; @@ -78,10 +73,6 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor int quadIndex = 0; int drawCount = skeleton.DrawOrder.Count; Color currentColor = new Color(); - -#if UNITY_EDITOR - Vector3 min = new Vector3(float.MaxValue, float.MaxValue, 0), max = new Vector3(float.MinValue, float.MinValue, 0); -#endif for (int i = 0; i < drawCount; i++) { Slot slot = skeleton.DrawOrder[i]; @@ -123,23 +114,8 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor triangles[index + 5] = vertexIndex + 1; quadIndex++; -#if UNITY_EDITOR - min = Vector3.Min(min, vertices[vertexIndex + 0]); - min = Vector3.Min(min, vertices[vertexIndex + 1]); - min = Vector3.Min(min, vertices[vertexIndex + 2]); - min = Vector3.Min(min, vertices[vertexIndex + 3]); - max = Vector3.Max(max, vertices[vertexIndex + 0]); - max = Vector3.Max(max, vertices[vertexIndex + 1]); - max = Vector3.Max(max, vertices[vertexIndex + 2]); - max = Vector3.Max(max, vertices[vertexIndex + 3]); -#endif } } -#if UNITY_EDITOR - float width = max.x - min.x, height = max.y - min.y; - gizmosCenter = new Vector3(min.x + width / 2, min.y + height / 2, 0); - gizmosSize = new Vector3(Mathf.Abs(width), Mathf.Abs(height), 1); -#endif mesh.Clear(); @@ -161,15 +137,10 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor } renderer.sharedMaterial = skeletonDataAsset.spritesData.inst.materials[0]; - } - #if UNITY_EDITOR - void OnDrawGizmos() { - Gizmos.color = Color.clear; - Gizmos.matrix = transform.localToWorldMatrix; - Gizmos.DrawCube(gizmosCenter, gizmosSize); - } + UpdateEditorGizmo(); #endif + } private void UpdateCache() { int quadCount = 0; @@ -221,4 +192,30 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor 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 } From 554c3186755c48c6ec43d0591c781b49e3efdf98 Mon Sep 17 00:00:00 2001 From: Alex Swan Date: Mon, 17 Jun 2013 17:13:11 -0600 Subject: [PATCH 5/5] Removed reference to non-existant 'ipad' and 'ipadhd' directory --- spine-cocos2dx/example/Classes/AppMacros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spine-cocos2dx/example/Classes/AppMacros.h b/spine-cocos2dx/example/Classes/AppMacros.h index 385f8311d..16c4b8d54 100755 --- a/spine-cocos2dx/example/Classes/AppMacros.h +++ b/spine-cocos2dx/example/Classes/AppMacros.h @@ -63,8 +63,8 @@ typedef struct tagResource { static Resource smallResource = {cocos2d::CCSizeMake(480, 320), "iphone"}; static Resource mediumResource = {cocos2d::CCSizeMake(960, 640), "iphone-retina"}; -static Resource largeResource = {cocos2d::CCSizeMake(1024, 768), "ipad"}; -static Resource extralargeResource = {cocos2d::CCSizeMake(2048, 1536), "ipadhd"}; +static Resource largeResource = {cocos2d::CCSizeMake(1024, 768), "iphone"}; +static Resource extralargeResource = {cocos2d::CCSizeMake(2048, 1536), "iphone-retina"}; #if (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_480X320) static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(480, 320);