コード例 #1
0
    // d.pointerDrag is the object that was dragged
    public void OnDrop(PointerEventData d)
    {
        // one mouse button is enough for drag and drop
        if (dropable && d.button == button)
        {
            // was the dropped GameObject a UIDragAndDropable and was it dragable?
            // (Unity calls OnDrop even if .dragable was false)
            UIDragAndDropable dropDragable = d.pointerDrag.GetComponent <UIDragAndDropable>();
            if (dropDragable != null && dropDragable.dragable)
            {
                // let the dragable know that it was dropped onto a slot
                dropDragable.draggedToSlot = true;

                // only do something if we didn't drop it on itself. this way we
                // don't have to ignore raycasts etc.
                // message is sent to drag and drop handler for game specifics
                if (dropDragable != this)
                {
                    // send a drag and drop message like
                    // OnDragAndDrop_Skillbar_Inventory({from, to})
                    Player player = Utils.ClientLocalPlayer();
                    int    from   = dropDragable.name.ToInt();
                    int    to     = name.ToInt();
                    player.SendMessage("OnDragAndDrop_" + dropDragable.tag + "_" + tag,
                                       new int[] { from, to },
                                       SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    }
コード例 #2
0
 public void OnDrop(PointerEventData d)
 {
     if (dropable && d.button == button)
     {
         UIDragAndDropable dropDragable = d.pointerDrag.GetComponent <UIDragAndDropable>();
         if (dropDragable != null && dropDragable.dragable)
         {
             dropDragable.draggedToSlot = true;
             if (dropDragable != this)
             {
                 int from = dropDragable.name.ToInt();
                 int to   = name.ToInt();
                 Player.localPlayer.SendMessage("OnDragAndDrop_" + dropDragable.tag + "_" + tag,
                                                new int[] { from, to },
                                                SendMessageOptions.DontRequireReceiver);
             }
         }
     }
 }
コード例 #3
0
    void OnDragAndClear(UIDragAndDropable entry)
    {
        if (!isLocalPlayer)
        {
            return;
        }

        // get the corresponding synclist index from the name
        int from = entry.name.ToInt();

        // clear it for some slot types
        if (entry.tag == "SkillbarSlot")
        {
            player.skillbar[from] = "";
        }
        if (entry.tag == "TradingSlot")
        {
            player.CmdTradeOfferItemClear(from);
        }
    }