Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (!dragging)
        {
            return;
        }

        var possibleDropZone = col.GetComponent <IDropZone>();

        if (possibleDropZone == null || !possibleDropZone.CanDrop(this))
        {
            return;
        }

        foreach (var dropZone in newDropZones)
        {
            dropZone.OnDragExit(this);
        }

        newDropZones.Insert(0, possibleDropZone);
        newDropZones[0].OnDragEnter(this);
    }
Exemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (!dragging)
        {
            return;
        }

        var possibleDropZone = col.GetComponent <IDropZone>();

        if (possibleDropZone == null || !possibleDropZone.CanDrop(this))
        {
            return;
        }

        // Notify current potential drop zones they aren't first choice
        foreach (var dropZone in newDropZones)
        {
            dropZone.OnDragExit(this);
        }

        // Add new drop zone as first choice
        newDropZones.Insert(0, possibleDropZone);
        newDropZones[0].OnDragEnter(this);
    }