Exemple #1
0
    private void ToggleInventory()
    {
        //only toggle the inventory if in the normal game state/mode.
        if (GlobalGame.Instance.CurrentGameState == GlobalGame.GameState.Normal)
        {
            InventoryCanvas.gameObject.SetActive(!InventoryCanvas.gameObject.activeSelf);
        }

        //find first selectable button in inventory
        Toggle btn = InventoryCanvas.GetComponentInChildren <Toggle>();

        //if the inventory had just been set to active and there is a button that can be pressed then put it in focus.
        if (InventoryCanvas.gameObject.activeSelf)
        {
            if (OnInventoryOpen != null)
            {
                OnInventoryOpen.Invoke();
            }
            if (btn)
            {
                btn.Select();
            }
        }
    }