Ejemplo n.º 1
0
    public override void OnPointerEnter(PointerEventData eventData)
    {
        //Debug.Log("OnPointerEnter " + this.name, this);

        base.OnPointerEnter(eventData);

        FMInputController.GetOrCreateInstance().currentlyOver = this;
    }
Ejemplo n.º 2
0
    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;
    }
Ejemplo n.º 3
0
    public override void OnPointerExit(PointerEventData eventData)
    {
        //Debug.Log("OnPointerExit " + this.name, this);

        base.OnPointerExit(eventData);

        if (FMInputController.GetOrCreateInstance().currentlyOver == this)
        {
            FMInputController.GetOrCreateInstance().currentlyOver = null;
        }
    }
Ejemplo n.º 4
0
    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;
    }
Ejemplo n.º 5
0
    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;
    }