Пример #1
0
    public override void HandleEvent(string eventName, object data)
    {
        switch (eventName)
        {
        case Consts.E_OpenBackpackToggle:
            //当接收到打开背包Toggle事件时
            GameObject go = transform.Find("0").gameObject;

            EventSystem.current.SetSelectedGameObject(go);
            break;

        case Consts.E_CloseBackpackToggle:

            OnToggleClosed();

            Debug.Log("关闭背包Toggle");

            break;

        case Consts.E_UserItem:
            UseItemArgs e = data as UseItemArgs;

            currentNeedUseItem = e.itemName;
            num = e.num;

            break;
        }
    }
Пример #2
0
    /// <summary>
    /// 使用物品事件,选择物品后调用
    /// </summary>
    void OnUseItemEvent()
    {
        //使背包里的物品不能被聚焦
        for (int i = 0; i < items.Count; i++)
        {
            items[i].GetComponent <Button>().interactable = false;
        }

        //显示Toggle
        ObjectManager.BackpackToggleGo.SetActive(true);

        //消隐Button,意味这个被选中
        currentSelectedItem.GetComponent <Image>().color = new Color(0.8f, 0.8f, 0.8f);

        //给主面板发送指令,让它把Toggle压入栈中
        SendEvent(Consts.E_OpenBackpackToggle);

        UseItemArgs e = new UseItemArgs();

        e.itemName = currentItemName;
        e.num      = 1;
        SendEvent(Consts.E_UserItem, e);
    }