public override void OnPointerEnter(PointerEventData eventData) { //Debug.Log("OnPointerEnter " + this.name, this); base.OnPointerEnter(eventData); FMInputController.GetOrCreateInstance().currentlyOver = this; }
void OnDisable() { //if being dragged, cancel if (FMInputController.GetOrCreateInstance().currentlyDragging == this.gameObject) { //FMInputController.GetOrCreateInstance().OnDropped(this.gameObject, FMInputController.GetOrCreateInstance().currentlyOver); FMInputController.GetOrCreateInstance().currentlyDragging = null; } GetComponent <Image>().raycastTarget = true; }
public override void OnPointerExit(PointerEventData eventData) { //Debug.Log("OnPointerExit " + this.name, this); base.OnPointerExit(eventData); if (FMInputController.GetOrCreateInstance().currentlyOver == this) { FMInputController.GetOrCreateInstance().currentlyOver = null; } }
public void OnBeginDrag(PointerEventData eventData) { if (m_DragReaction != null) { if (!m_DragReaction()) { return; } } //Debug.Log("BeginDrag " + this.name, this); var canvas = FindInParents <Canvas>(gameObject); if (canvas == null) { return; } // We have clicked something that can be dragged. // What we want to do is create an icon for this. if (dragCopy) { m_DraggingIcon = new GameObject("icon"); m_DraggingIcon.transform.SetParent(canvas.transform, false); m_DraggingIcon.transform.SetAsLastSibling(); var image = m_DraggingIcon.AddComponent <Image>(); image.sprite = GetComponent <Image>().sprite; image.SetNativeSize(); } if (dragOnSurfaces) { m_DraggingPlane = transform as RectTransform; } else { m_DraggingPlane = canvas.transform as RectTransform; } GetComponent <Image>().raycastTarget = false; SetDraggedPosition(eventData); FMInputController.GetOrCreateInstance().currentlyDragging = this.gameObject; }
public void OnEndDrag(PointerEventData eventData) { //Debug.Log("EndDrag " + this.name, this); if (m_DraggingIcon != null) { this.transform.position = m_DraggingIcon.transform.position; Destroy(m_DraggingIcon); } if (FMInputController.GetOrCreateInstance().currentlyDragging == this.gameObject) { FMInputController.GetOrCreateInstance().OnDropped(this.gameObject, FMInputController.GetOrCreateInstance().currentlyOver); FMInputController.GetOrCreateInstance().currentlyDragging = null; } GetComponent <Image>().raycastTarget = true; }