public void Show() { CharacterController2D.DisableMovement(); interactionController.DisableInteracting(); gameObject.SetActive(true); inventoryPanel.Show(InventoryState.MIXING); EventSystem.current.SetSelectedGameObject(slot0.gameObject); }
public void DisableInputs() { inventoryManager.HideMixingMenu(); inventoryManager.HideInventory(); CharacterController2D.DisableMovement(); InventoryManager.DisableInventory(); interactionController.DisableInteracting(); #if UNITY_ANDROID inventoryButton.SetActive(false); #endif }
public void Show(InventoryState state) { this.state = state; foreach (Transform children in contentPanel.transform) { Destroy(children.gameObject); } CharacterController2D.DisableMovement(); interactionController.DisableInteracting(); firstButton = null; List <string> items = Inventory.GetItems(); items.Sort(); List <Button> buttonList = new List <Button>(); for (int i = 0; i < items.Count; i++) { string id = items[i]; Item item = interactionsDataBase.GetItem(id); InventoryItem inventoryItem = Instantiate(inventoryItemPrefab); #if UNITY_ANDROID inventoryItem.GetComponent <Image>().raycastTarget = true; #endif inventoryItem.item = item; inventoryItem.icon.sprite = item.GetSprite(); inventoryItem.inventoryPanel = this; inventoryItem.index = i; inventoryItem.gameObject.name = "slot_" + id; Button btInventoryItem = inventoryItem.GetComponent <Button>(); #if !UNITY_ANDROID Navigation navigation = btInventoryItem.navigation; navigation.mode = Navigation.Mode.Explicit; #endif btInventoryItem.onClick.AddListener( delegate { OnItemSelected(inventoryItem.item); }); inventoryItem.transform.SetParent(contentPanel.transform, false); buttonList.Add(btInventoryItem); } #if !UNITY_ANDROID for (int i = 0; i < buttonList.Count; i++) { Button bt = buttonList[i]; Navigation navigation = bt.navigation; navigation.mode = Navigation.Mode.Explicit; if (i == 0) { navigation.selectOnLeft = buttonList[buttonList.Count - 1]; if (buttonList.Count == 1) { navigation.selectOnRight = buttonList[0]; } else { navigation.selectOnRight = buttonList[i + 1]; } } else if (i == buttonList.Count - 1) { navigation.selectOnLeft = buttonList[i - 1]; navigation.selectOnRight = buttonList[0]; } else { navigation.selectOnLeft = buttonList[i - 1]; navigation.selectOnRight = buttonList[i + 1]; } bt.navigation = navigation; } #endif gameObject.SetActive(true); if (buttonList.Count > 0) { firstButton = buttonList[0]; } if (state == InventoryState.LOOKING) { recipeBook.Show(); clock.Show(); } else { recipeBook.Hide(); } }