コード例 #1
0
    void Update()
    {
        if (_active != gameObject.activeSelf)
        {
            if (!_active)
            {
                OnInventoryChanged();
            }

            _active = gameObject.activeSelf;
        }

        // Shift click
        if (Input.GetKey(KeyCode.LeftShift))
        {
            if (Input.GetMouseButton(0))
            {
                if (mouseHovering && item.itemName != "")
                {
                    ShiftClick();
                }
            }
        }

        // Left click
        if (Input.GetMouseButtonDown(0))
        {
            if (mouseHovering)
            {
                if (item.itemName != "" || inventoryUI.GetItemAtMouse() != null)
                {
                    MoveToMouse();
                }
            }
        }

        if (mouseHovering)
        {
            if (item != null)
            {
                if (item.itemName != "")
                {
                    string desc = item.itemDescription;
                    if (item.Amount > 1)
                    {
                        desc += "\nYou have " + item.Amount + " of these.";
                    }
                    tooltip.ChangeText(item.itemName, desc);
                    tooltip.SetPosition(new Vector2(Input.mousePosition.x, Input.mousePosition.y - 100f + tooltip.BodyHeight()));
                }
            }
        }
    }