// if an item is selected, keep track of it public void itemSelected(GameObject obj) { ItemAbstract item; if (!iconsMode) { UnityEngine.UI.Text indexItem = obj.transform.GetChild(0). GetComponent <UnityEngine.UI.Text>(); item = ItemDefinitions.stringToItem( indexItem.text.Substring(0, indexItem.text.Length - 4)); } else { item = ItemDefinitions.stringToItem( obj.GetComponent <ItemBasic>().itemString); } if (itemImage != null) { GameObject imgObj = itemImage; UnityEngine.UI.Image img = null; if (imgObj != null) { img = imgObj.GetComponent <UnityEngine.UI.Image>(); } if (img != null) { img.sprite = getImage(item); } } if (panel1 != null) { panel1.GetComponent <UnityEngine.UI.Text>() .text = ItemDefinitions.getDesc(item); } if (panel2 != null) { panel2.GetComponent <UnityEngine.UI.Text>() .text = ItemDefinitions.getSpec(item); } if (alchemizeButton != null) { alchemizeButton.GetComponent <AlchemizeButton>() .itemSelected(item); } selectedItem = obj; }