void UpdateCount(Transform tr, Item item)
{
if (item.stack == 1) {
// do nothing or delete count text
Transform txt2 = tr.FindChild ("Stack");
if (txt2 != null) {
txt2.transform.parent = null;
DestroyImmediate (txt2);
}
return;
}
// update text or create new text
Transform txt1 = tr.FindChild ("Stack");
GameObject label = txt1 != null ? txt1.gameObject : null;
if (txt1 == null) {
label = Instantiate(inventoryStackLabel);
label.transform.SetParent(tr);
label.transform.localPosition = new Vector3 ();
label.name = "Stack";
}
var comp = label.GetComponent<Text> ();
comp.text = item.stack.ToString ();
}