public void UpdateInventoryUI() { if (structureState.checkHasItems() || structureState.checkFull()) { foreach (GameObject image in images) { bool notFoundItem = true; foreach (GameObject item in structureState.inventory) { if (item.GetComponent <Interact>().interactName == image.name.Substring("Image_".Length)) { image.SetActive(true); int counter = structureState.countItemsByName(item.GetComponent <Interact>().interactName); if (counter > 1) { image.GetComponentInChildren <Text>().text = counter.ToString(); } else { image.GetComponentInChildren <Text>().text = ""; } notFoundItem = false; } } if (notFoundItem) { image.SetActive(false); } } } if (structureState.checkEmpty()) { foreach (GameObject image in images) { image.SetActive(false); } } if (structureState.checkFull()) { craftButton.SetActive(true); } else { craftButton.SetActive(false); confirmButton.SetActive(false); } inventoryCounterText.text = structureState.inventory.Count.ToString() + "/" + structureState.capacity; }