示例#1
0
    void SwapActiveAction(Object sender, int index)
    {
        if (!activeActionCooldown)
        {
            if (index <= actionBarSize)
            {
                activeActionIndex = index;
                actionBars.SetActive(index);

                if (testActionBarList[index] != null)
                {
                    activeItem.data         = testActionBarList[index].data;
                    activeItem.whatIsTarget = testActionBarList[index].whatIsTarget;
                }
                else
                {
                    activeItem.data         = emptyItem.data;
                    activeItem.whatIsTarget = emptyItem.whatIsTarget;
                }

                InventoryEventManager.ActiveItemSwap(this, activeItem);
                StartCoroutine(ActionCooldown());
            }
        }
    }
    // Update is called once per frame
    private void OnGUI()
    {
        if (TestItemPrefab == null || !GUI.Button(new Rect(200, 200, 50, 100), "Click to add to inventory"))
        {
            return;
        }
        var instantiate = Instantiate(_other ? TestItemPrefab : TestItemPrefab2, transform, false);

        var itemStack = ItemStack.Of(instantiate);

        InventoryEventManager.PickupItem(itemStack);

        _other = !_other;
    }