public void OnBeginDrag(PointerEventData eventData)
    {
        if (!spawn)
        {
            Instantiate(gameObject, panel.transform);
            spawn = true;

            transform.GetComponent <CodeBlock>().EditChildParameters();
        }
        else
        {
            lastPos = dragRectTransform.anchoredPosition;
        }

        RaycastHit2D ray = Physics2D.Raycast(transform.position, Vector2.down, (40 * transform.parent.localScale.x));


        blockColor   = transform.GetChild(0).GetComponent <Image>().color;
        blockColor.a = 0.6f;
        transform.GetChild(0).GetComponent <Image>().color = blockColor;

        transform.SetParent(canvas.gameObject.transform);
        dragRectTransform.SetAsLastSibling();
        transform.localScale = contentPanel.transform.localScale;

        collisionDetected = false;

        if (ray)
        {
            if (ray.collider.GetComponent <DraggeableWindow>() != null)
            {
                nextBlock = ray.collider.GetComponent <DraggeableWindow>();
                nextBlock.OnBeginDrag(eventData);
            }
        }
        else
        {
            nextBlock = null;
        }
    }
Exemplo n.º 2
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        RaycastHit2D ray = Physics2D.Raycast(transform.position, Vector2.down, (40 * transform.parent.localScale.x));


        transform.SetParent(canvas.gameObject.transform);
        dragRectTransform.SetAsLastSibling();
        transform.localScale = contentPanel.transform.localScale;

        collisionDetected = false;


        if (ray)
        {
            nextBlock = ray.collider.GetComponent <DraggeableWindow>();
            nextBlock.OnBeginDrag(eventData);
        }
        else
        {
            nextBlock = null;
        }
    }