当拾取物品后,添加物品到背包栏,通过回调函数来销毁 场景中的 掉落在场景当中 刚才被拾取的 物品 实体。

 

 

Inventory.cs

...
    //回调函数
    public delegate void callback_pickUpItem(int a);
///当 把物品添加到物品栏之后
    public void addItemToInventory(ItemDropData itemDropData,callback_pickUpItem callback_)
    {
        callback_(0);
    }//
...

 

ItemPickUp.cs

...
    /// <summary>
    /// 掉落 物品 数据
    /// </summary>
    private ItemDropData dropData = null;
...
    Inventory cb_Inventory = new Inventory();

    /// <summary>
    /// 拾取动画播放完毕,播放 拾取音效,并且添加物品到背包中。
    /// </summary>
    public void addItemIntoInventory()
    {
        if (uIInventoryManager != null
            //&& uIInventoryManager.canPickUpItem(dropData)
            )
        {
            //uIInventoryManager.pickUpItem(this);
            //当添加完 物品到 物品栏 之后,销毁场景中 的拾取物品
            cb_Inventory.addItemToInventory(dropData, destoryItemDrop);
        }//
    }//


    private void destoryItemDrop(int i)
    {
        Debug.Log("    destoryItemDrop  ");
        //Destroy(this);
    }//
...

 

 

 

本文地址:https://blog.csdn.net/BuladeMian/article/details/109262556