public static ChannelInfo create(ChannelInfoRaw item) { int channelUIId = item.type * setting.MaxChannel + item.id; GameObject clone; if (true) { clone = Instantiate(commonObj.ListItemPrefab, Vector3.zero, Quaternion.identity) as GameObject; clone.transform.Find("Text").GetComponent <Text> ().text = setting.DateTypeName[item.type] + "(" + item.id + ")" + ":" + item.count; ChannelInfo channelTemp = clone.GetComponent <ChannelInfo> (); clone.GetComponents <Button> () [0].onClick.AddListener( () => channelTemp.onClickItem()); } else { clone = new GameObject(); clone.AddComponent <ChannelInfo> (); } ChannelInfo channel = clone.GetComponent <ChannelInfo> (); channel.id = item.id; channel.type = item.type; channel.name = item.name; channel.count = item.count; channel.ListId = channelUIId; clone.name = channelUIId.ToString(); clone.transform.SetParent(commonObj.listRoot, false); channel.initMenu(); return(channel); }
//data file related public void onReadFileBtn() { int channelId = Int32.Parse(curChennel.text); int count = CppInterface.ReadSingleData(FileAddrUI, FileTypeUI, channelId); if (count > 0) { ChannelInfoRaw channelItem = new ChannelInfoRaw(); channelItem.type = FileTypeUI; channelItem.id = channelId; channelItem.count = count; ChannelInfo uiItem = addListUI(channelItem); uiItem.showTog.isOn = true; if (FileTypeUI == 1) //mp { } if (FileTypeUI == 2) //kf { } if (FileTypeUI == 3) //road { } if (FileTypeUI == 4) //features { } if (FileTypeUI == 5) //images { } } }
public ChannelInfo addListUI(ChannelInfoRaw item) { int listID = item.type * setting.MaxChannel + item.id; removeListUI(listID); return(ChannelInfo.create(item)); }
public static List <ChannelInfoRaw> GetChannelInfo(int type) { List <ChannelInfoRaw> re = new List <ChannelInfoRaw> (); for (int i = 0; i < setting.MaxChannel; i++) { int count = GetListCount(type, i); if (count > 0) { ChannelInfoRaw item = new ChannelInfoRaw(); //string channelName = GetChannelName (type, i); item.count = count; item.type = type; item.id = i; item.name = "null"; re.Add(item); } } return(re); }