protected override void OnEnable() { if (Inventory == null) { InventoryWindow.SetActive(false); return; } if (currentSlotCount > Inventory.InventorySlotCount) { for (int i = Inventory.InventorySlotCount; i < currentSlotCount; i++) { Destroy(InventorySlotsUI[i].transform.parent.gameObject); } InventorySlotsUI.RemoveRange(Inventory.InventorySlotCount, currentSlotCount - Inventory.InventorySlotCount); } else if (currentSlotCount < Inventory.InventorySlotCount) { for (int i = currentSlotCount; i < Inventory.InventorySlotCount; i++) { InventorySlotsUI.Add(Instantiate(inventorySlotPrefab, Vector3.zero, Quaternion.identity, gameObject.transform).GetComponentInChildren <InventorySlotUI>()); InventorySlotsUI[i].SlotIndex = i; InventorySlotsUI[i].InventoryUI = this; } } currentSlotCount = Inventory.InventorySlotCount; rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.CeilToInt((float)currentSlotCount / 3) * 120); UpdateInventorySlotsUI(); Inventory.SlotUpdatedEvent += OnSlotUpdatedEvent; }
private void Update() { if (pauseMenuUnlocked) { if (Input.GetKeyDown(pauseKey)) { LockActionsAndOpenMenu(!actionsUnlocked); } if (actionsUnlocked) { if (Input.GetKeyDown(inventoryKey)) { inventoryWindow.SetActive(!inventoryWindow.IsActive); } if (interactableObject && Input.GetKeyDown(interactionKey)) { interactableObject.Interact(); } } } }
private void RenderActive(bool isactive) { inventoryWindow.SetActive(activeId, isactive); }
public void Inventory(bool Opening) { Open = Opening; InventoryWindow.SetActive(Opening); InventoryButton.SetActive(!Opening); }