private void AddingItems() { keyList.Clear(); keyList.AddRange(SelectedGameobject.GetComponentInParent <ResourceBuildingsManagment>().StoredResources.Keys); storedResourceList.Clear(); foreach (Transform child in ScrollViewContent.transform) { Destroy(child.gameObject); } foreach (var Resource in keyList) { if (SelectedGameobject.GetComponentInParent <ResourceBuildingsManagment>().StoredResources[Resource] != 0) { storedResourceList.Add(Resource); continue; } } foreach (var storedResource in storedResourceList) { var Item = Instantiate(ItemImagePrefab, ScrollViewContent.transform); Item.transform.GetChild(0).GetComponent <TextMeshProUGUI>().SetText(storedResource); Item.transform.GetChild(1).GetComponent <TextMeshProUGUI>().SetText(SelectedGameobject.GetComponentInParent <ResourceBuildingsManagment>().StoredResources[storedResource].ToString()); Item.name = storedResource; } }
private void Update() { if (this.enabled) { if (SelectedGameobject == null) { return; } foreach (var item in SelectedGameobject.GetComponentInParent <ResourceBuildingsManagment>().StoredResources) { if (item.Value != 0) { if (storedResourceList.Contains(item.Key)) { continue; } else { storedResourceList.Add(item.Key); } } } if (storedResourceList.Count != ScrollViewContent.transform.childCount || SelectedGameobject != savedeGameObject) { AddingItems(); } foreach (var Resource in storedResourceList) { if (SelectedGameobject.GetComponentInParent <ResourceBuildingsManagment>().StoredResources[Resource] != Convert.ToInt32(ScrollViewContent.transform.Find(Resource).transform.GetChild(1).GetComponent <TextMeshProUGUI>().text)) { ScrollViewContent.transform.Find(Resource).transform.GetChild(1).GetComponent <TextMeshProUGUI>().SetText(SelectedGameobject.GetComponentInParent <ResourceBuildingsManagment>().StoredResources[Resource].ToString()); } } UpdateUiBuildingInformationen(); } }