void OnEnable() { _instance = this; itemList.Clear(); // @ToDo: select items depending on NPC level and area foreach (Item itm in Service.db.Select <Item>("FROM item limit 0," + MAX_ITEMS)) { itemList.Add(itm); } ScrollableList scroll = scrollPanel.GetComponent <ScrollableList>(); scroll.itemCount = MAX_ITEMS; scroll.load(delegate(GameObject newItem, int num) { Item tItem = itemList[num]; Vector3 price = Util.formatMoney(tItem.price); newItem.SetActive(true); newItem.gameObject.transform.Find("Button/NameLabel").GetComponent <Text>().text = tItem.name; newItem.gameObject.transform.Find("Button/GalleonLabel").GetComponent <Text> ().text = price.x.ToString(); newItem.gameObject.transform.Find("Button/SickleLabel").GetComponent <Text> ().text = price.y.ToString(); newItem.gameObject.transform.Find("Button/KnutLabel").GetComponent <Text> ().text = price.z.ToString(); newItem.gameObject.transform.Find("Icon").GetComponent <RawImage> ().texture = tItem.icon; newItem.gameObject.transform.Find("Button").GetComponent <Button>().onClick.AddListener( delegate { selectedItem = tItem; }); return(newItem); }); updateMoney(); }