mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
Merge pull request #66 from Yonsh/patch-1
Fix: Unable to select in editor when flipped
This commit is contained in:
commit
d03ec8463c
@ -137,6 +137,9 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
|
||||
}
|
||||
|
||||
renderer.sharedMaterial = skeletonDataAsset.spritesData.inst.materials[0];
|
||||
#if UNITY_EDITOR
|
||||
UpdateEditorGizmo();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void UpdateCache() {
|
||||
@ -189,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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user