Пример #1
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        if (inputHandler.Dragging)
        {
            return;                    // So only one item can be dragged at a time.
        }
        if (!item.DecorationActive())
        {
            Debug.Log(item.name + " not active!");
            return;
        }
        ;

        inputHandler.Dragging = true;

    #if UNITY_EDITOR
        offset = Input.mousePosition - transform.position;
#elif UNITY_ANDROID
        if (Input.touchCount > 0)
        {
            Touch   touch    = Input.GetTouch(0);
            Vector3 touchPos = touch.position;
            offset = touchPos - transform.position;
        }
#endif

        // Basically sets the item to be the front-most element after buttons.
        transform.SetSiblingIndex(canvas.childCount - 5);
        inputHandler.SetRectTransform(rectTransform);
    }