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); diff --git a/spine-tk2d/Code/tk2dSpineSkeleton.cs b/spine-tk2d/Code/tk2dSpineSkeleton.cs index 171c4bf0f..7ca777246 100644 --- a/spine-tk2d/Code/tk2dSpineSkeleton.cs +++ b/spine-tk2d/Code/tk2dSpineSkeleton.cs @@ -124,6 +124,11 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor mesh.tangents = tangents; } } + + renderer.sharedMaterial = skeletonDataAsset.spritesData.inst.materials[0]; +#if UNITY_EDITOR + UpdateEditorGizmo(); +#endif } private void UpdateCache() { @@ -200,4 +205,30 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor 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-unity/Assets/Plugins/Spine/SkeletonComponent.cs b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs index 46d904a33..565996c45 100644 --- a/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs +++ b/spine-unity/Assets/Plugins/Spine/SkeletonComponent.cs @@ -165,6 +165,9 @@ public class SkeletonComponent : MonoBehaviour { mesh.colors32 = colors; mesh.uv = uvs; if (newTriangles) mesh.triangles = triangles; +#if UNITY_EDITOR + UpdateEditorGizmo(); +#endif } public virtual void OnEnable () { @@ -179,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 }