// Use this for initialization void Start() { _instance = this; // @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 = gameObject.transform.FindChild("ContainerPanel/Panel").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.FindChild("NameLabel").GetComponent<Text>().text = tItem.name; newItem.gameObject.transform.FindChild ("GalleonLabel").GetComponent<Text> ().text = price.x.ToString(); newItem.gameObject.transform.FindChild ("SickleLabel").GetComponent<Text> ().text = price.y.ToString(); newItem.gameObject.transform.FindChild ("KnutLabel").GetComponent<Text> ().text = price.z.ToString(); newItem.gameObject.transform.FindChild ("Icon").GetComponent<RawImage> ().texture = tItem.icon; newItem.gameObject.transform.FindChild("Button").GetComponent<Button>().onClick.AddListener( delegate { selectedItem = tItem; }); return newItem; }); updateMoney(); }
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(); }