Fix: Unable to select in editor when flipped

http://www.esotericsoftware.com/forum/viewtopic.php?f=3&t=823
This commit is contained in:
Yonsh 2013-06-15 13:21:45 +09:00
parent baa70fa810
commit 4603b7eed3

View File

@ -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;