void HostFound() { if (panelManager.CurrentPanel.name == "JoinServerPanel") { WaitingSearchBox.Hide(true); IPConnect.SetActiveRecursively(true); } IP_List.ClearList(true); foreach (string tmpip in ips) { GameObject tmpLine = Instantiate(IP_Line) as GameObject; tmpLine.GetComponent <UIListItemContainer>().Text = tmpip; UIButton tmpBtn = tmpLine.transform.FindChild("IP_join").GetComponent <UIButton>(); tmpBtn.AddValueChangedDelegate(ConnectToIP); IP_List.AddItem(tmpLine); } for (int i = ips.Count; i < 5; i++) { GameObject tmpLine = Instantiate(IP_Line) as GameObject; UIButton tmpBtn = tmpLine.transform.FindChild("IP_join").GetComponent <UIButton>(); tmpBtn.SetControlState(UIButton.CONTROL_STATE.DISABLED); tmpBtn = tmpLine.transform.FindChild("IP_icon").GetComponent <UIButton>(); tmpBtn.SetControlState(UIButton.CONTROL_STATE.DISABLED); tmpBtn = tmpLine.transform.FindChild("IP_Bg").GetComponent <UIButton>(); tmpBtn.SetControlState(UIButton.CONTROL_STATE.DISABLED); IP_List.AddItem(tmpLine); } }
void AddEmail(EZTransition transition) { GameObject t = GameObject.Instantiate(inviteFriendPrefab) as GameObject; t.transform.FindChild("TextField").GetComponent <UITextField>().AddFocusDelegate(CreateInviteFriendsContainer); inviteFriendScroll.AddItem(t.GetComponent <UIListItemContainer>()); }
// Obtem as informacoes dos amigos do usuario void HandleGetFriends(string error, IJSonObject data, object counter_o) { Debug.Log(data); int counter = (int)counter_o; Flow.game_native.stopLoading(); UIManager.instance.blockInput = false; if (error != null || data == null) { if (counter > 0) { GameJsonAuthConnection conn = new GameJsonAuthConnection(Flow.URL_BASE + "login/friends/list.php", HandleGetFriends); conn.connect(null, counter - 1); return; } Flow.game_native.showMessage("Error", error); return; } string allLetter = ""; string playingLetter = ""; if (data.Count > 0) { allLetter = data[0]["name"].StringValue.Substring(0, 1).ToUpper(); GameObject firstL = GameObject.Instantiate(letterPrefab) as GameObject; firstL.transform.FindChild("Letter").GetComponent <SpriteText>().Text = allLetter.ToUpper(); scroll.AddItem(firstL); } foreach (IJSonObject friend in data.ArrayItems) { GameObject allContainer = CreateFriendContainer(friend); if (friend["name"].StringValue.Substring(0, 1).ToUpper() != allLetter) { allLetter = friend["name"].StringValue.Substring(0, 1).ToUpper(); GameObject l = GameObject.Instantiate(letterPrefab) as GameObject; l.transform.FindChild("Letter").GetComponent <SpriteText>().Text = allLetter.ToUpper(); scroll.AddItem(l); } scroll.AddItem(allContainer); } if (data.Count == 0) { noFriendsLabel.gameObject.SetActive(true); } else { noFriendsLabel.gameObject.SetActive(false); } }
public void Init( UIScrollList _list, body2_SC_PRIVATESHOP_SEARCH_RESULT _item, delListBtnClicked _del) { m_SearchInfo = _item; m_Del = _del; listBtn.SetInputDelegate( OnListButton); _list.AddItem( container); Item item = ItemMgr.ItemManagement.GetItem( _item.sItem.nItemTableIdx); GameObject objIcon = item.GetIcon(); objIcon = Instantiate( objIcon) as GameObject; objIcon.transform.parent = objSlot.transform; objIcon.transform.localPosition = Vector3.zero; count_ = objIcon.GetComponentInChildren<SpriteText>(); if( count_ != null && m_SearchInfo.sItem.nOverlapped > 1) count_.Text = m_SearchInfo.sItem.nOverlapped.ToString(); // item number must be added txt_Grade.Text = item.GetStrGrade(); txt_Level.Text = item.ItemData.levelLimit.ToString(); string str = m_SimpleName = AsTableManager.Instance.GetTbl_String(item.ItemData.nameId); if( m_SearchInfo.sItem.nStrengthenCount > 0) str = Color.white + "+" + m_SearchInfo.sItem.nStrengthenCount + " " + m_SimpleName; txt_Name.Text = str; // txt_Price.Text = _item.nItemGold.ToString(); txt_Price.Text = _item.nItemGold.ToString("#,#0", CultureInfo.InvariantCulture); container.ScanChildren(); container.GetScrollList().ClipItems(); }
void Start() { UIScrollList scrollList = FindControlByName <UIScrollList> ("Scroll View"); scrollList.SetLayout(UIScrollList.UILayoutDirection.HORIZONTAL_LEFT); scrollList.ItemSize = new Vector2(120, 120); scrollList.ContentSize = new Vector2(180, 180); scrollList.SetPadding(new RectOffset(20, 20, 0, 0)); scrollList.SetSpacing(30); foreach (KeyValuePair <string, string> item in _Images) { scrollList.AddItem(CreateButton(item.Key, item.Key, (UIControl ui) => { UIButton btn = (UIButton)ui; if (_LastTouchUI != null) { _LastTouchUI.Label.Color = Color.white; _LastTouchUI.Background.Alpha = 1; } btn.Label.Color = Color.red; btn.Background.Alpha = 0.5f; SetImageUrl(item.Value); _LastTouchUI = btn; })); } _Image = FindControlByName <UIImage> ("Image"); KeyboardListener.Instance.AddDispatch(this.gameObject, KeyCode.Delete, (TouchPhase phase) => { if (phase != TouchPhase.Began) { return; } if (_LastTouchUI != null) { _LastTouchUI.Label.Color = Color.white; _LastTouchUI.Background.Alpha = 1; } SetImageUrl(""); _LastTouchUI = null; }); SetImageUrl(""); UIDropdown dropDown = FindControlByName <UIDropdown> ("Dropdown"); dropDown.RemoveAllOptions(); dropDown.AddOption("地块层"); dropDown.AddOption("建筑层"); dropDown.AddOption("角色层"); dropDown.OnValueChanged.AddListener((int arg0) => { SetEnableLayer(arg0); }); }
public void AddItem(GameObject ObjectItem, int Index, GameObject Image, GameObject Name) { Image = (GameObject)Instantiate(Image); Name = (GameObject)Instantiate(Name); Image.transform.position = new Vector3(50, -115, 0); Image.GetComponent <UIButton>().SetAnchor(UIButton.ANCHOR_METHOD.BOTTOM_CENTER); Image.GetComponent <UIButton>().width = Image.GetComponent <UIButton>().ImageSize.x; Image.GetComponent <UIButton>().height = Image.GetComponent <UIButton>().ImageSize.y; Image.layer = LayerMask.NameToLayer("GUI"); Name.transform.position = new Vector3(90, -5, 0); Name.GetComponent <SpriteText>().Text = "Name"; Name.GetComponent <SpriteText>().SetAnchor(SpriteText.Anchor_Pos.Upper_Center); ObjectItem = (GameObject)Instantiate(ObjectItem); ObjectItem.GetComponent <UIListItemContainer>().MakeChild(Image); ObjectItem.GetComponent <UIListItemContainer>().MakeChild(Name); ObjectItem.GetComponent <UIListItemContainer>().Data = Index; ScrollList.AddItem(ObjectItem); }
// Use this for initialization public override void Start() { base.Start(); if (Application.loadedLevel == 0) { for (var i = 0; i < 10; i++) { var newItem = scrollList.CreateItem(listItemPrefab); scrollList.AddItem(newItem); } scrollList.PositionItems(); scrollList.snap = true; scrollList.SetInputDelegate(OnNextButtonPress); } }
public void RefreshItemsScroll(bool start = false) { if (!start) { goodsScroll.ClearList(true); } ShopItem[] allItems = Flow.config.GetComponent <ConfigManager>().shopItems; List <ShopItem> tList = new List <ShopItem>(); foreach (ShopItem si in allItems) { if (!si.hide) { tList.Add(si); } } ShopItem[] shopItems = tList.ToArray(); items = shopItems.Length; //foreach (ShopItem si in shopItems) if(!si.hide) items++; pages = items / itemsPerPage; itemsLastPage = items % itemsPerPage; if (itemsLastPage != 0) { pages++; } else { itemsLastPage = itemsPerPage; } //Debug.Log("pages: "+ pages); for (int i = 0; i < pages; i++) { int itemsOnPage = itemsPerPage; if (i == pages - 1) { itemsOnPage = itemsLastPage; } //Debug.Log("items on page: "+ itemsOnPage); GameObject tempPage = Instantiate(goodsPage) as GameObject; for (int j = 0; j < itemsOnPage; j++) { tempPage.transform.FindChild("Item" + j).GetComponent <ShopInfo>().id = shopItems[(i * itemsPerPage) + j].id; tempPage.transform.FindChild("Item" + j).FindChild("BuyButton").GetComponent <UIButton>().Text = shopItems[(i * itemsPerPage) + j].name; tempPage.transform.FindChild("Item" + j).FindChild("Price").FindChild("Label").GetComponent <SpriteText>().Text = shopItems[(i * itemsPerPage) + j].coinPrice.ToString(); if (shopItems[(i * itemsPerPage) + j].image != null) { tempPage.transform.FindChild("Item" + j).FindChild("ItemImage").GetComponent <MeshRenderer>().material.mainTexture = shopItems[(i * itemsPerPage) + j].image; } else { tempPage.transform.FindChild("Item" + j).GetComponent <ShopInfo>().DownloadImage(); } // se tem o item, arruma seu transform if (Save.HasKey(PlayerPrefsKeys.ITEMSPACK + tempPage.transform.FindChild("Item" + j).GetComponent <ShopInfo>().id)) { tempPage.transform.FindChild("Item" + j).FindChild("Purchased").gameObject.SetActive(true); tempPage.transform.FindChild("Item" + j).FindChild("Price").gameObject.SetActive(false); tempPage.transform.FindChild("Item" + j).GetComponent <ShopInfo>().has = true; } } for (int k = itemsOnPage; k < itemsPerPage; k++) { tempPage.transform.FindChild("Item" + k).gameObject.SetActive(false); } goodsScroll.AddItem(tempPage.GetComponent <UIListItemContainer>()); } }