// Update is called once per frame void FixedUpdate() { for (int i = 0; i < transform.childCount; i++) { var go = transform.GetChild(i).gameObject; string name = go.name; if (name.Contains("BG") || name.ToUpper().Contains("TOTALCOUNTER")) { } else { InventoryCounter itemCounter = go.GetComponentInChildren(typeof(InventoryCounter)) as InventoryCounter; itemCounter.counter = Inventory.getInventoryQuantity(name); string selectedItem = Inventory.currentItem(); var image = go.GetComponentInChildren(typeof(Image)) as Image; var selected = image.transform.GetChild(0).GetComponent(typeof(Image)) as Image; if (selectedItem.ToUpper().Contains(name.ToUpper()) && itemCounter.counter > 0) { selected.enabled = true; } else { selected.enabled = false; } } } }
// Update is called once per frame void Update() { List <GameObject> items = new List <GameObject>(); for (int i = 0; i < transform.childCount; i++) { items.Add(transform.GetChild(i).gameObject); } foreach (GameObject go in items) { if (go.name.ToUpper().Contains("CLAVIER")) { InventoryCounter clavierCounter = go.GetComponentInChildren(typeof(InventoryCounter)) as InventoryCounter; clavierCounter.counter++; } } }