using UnityEngine; using System.Collections; using System.Collections.Generic; namespace Wing.Gizmos { public class GizmosAxis : MonoBehaviour { private GizmosBase _coordinate; private int m_iLayer; private bool mSelected = false; // Use this for initialization void Awake() { _coordinate = transform.parent.parent.GetComponent(); m_iLayer = LayerMask.NameToLayer(Settings.GizmosLayerName); gameObject.layer = m_iLayer; } // Update is called once per frame void Update() { if (mSelected) { if (!Input.GetMouseButton(0)) { mSelected = false; StartCoroutine(delayRelease()); } else { _coordinate.OnMouseDrag(gameObject); } } else if(Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000, 1 << m_iLayer)) { if (hit.collider.gameObject == gameObject) { _coordinate.OnMouseEnter(gameObject); _coordinate.OnMouseDown(gameObject); mSelected = true; } } } } IEnumerator delayRelease() { yield return new WaitForEndOfFrame(); _coordinate.OnMouseExit(gameObject); _coordinate.OnMouseUp(gameObject); } } }