public void updateUI() { initServerButtons(ServerManagerment.Instance.lastServer); for (int i = 0; i < ScrollContent.transform.childCount; i++) { GameObject go = ScrollContent.transform.GetChild(i).gameObject; DestroyImmediate(go); } List <Json_ServerInfo> serverList = ServerManagerment.Instance.getAllServer(); foreach (Json_ServerInfo each in serverList) { GameObject obj = NGUITools.AddChild(ScrollContent.gameObject, serverButtonPrefab); ServerButton button = obj.GetComponent <ServerButton> (); button.initButton(each); button.fatherWindow = this; obj.AddComponent <UIDragScrollView> (); } UIGrid grid = ScrollContent.GetComponent <UIGrid> (); grid.enabled = true; grid.Reposition(); if (GuideManager.Instance.guideUI != null) { GuideManager.Instance.hideGuideUI(); } if (serverList.Count > 8) { downArrow.SetActive(true); } }
/* methods */ protected override void DoEnable() { base.DoEnable(); UiManager.Instance.backGround.switchBackGround("loginBackGround"); initServerButtons(ServerManagerment.Instance.lastServer); List <Json_ServerInfo> serverList = ServerManagerment.Instance.getAllServer(); foreach (Json_ServerInfo each in serverList) { GameObject obj = NGUITools.AddChild(ScrollContent.gameObject, serverButtonPrefab); ServerButton button = obj.GetComponent <ServerButton> (); button.initButton(each); button.fatherWindow = this; obj.AddComponent <UIDragScrollView> (); } UIGrid grid = ScrollContent.GetComponent <UIGrid> (); grid.enabled = true; grid.Reposition(); if (GuideManager.Instance.guideUI != null) { GuideManager.Instance.hideGuideUI(); } if (serverList.Count > 8) { downArrow.SetActive(true); } MaskWindow.UnlockUI(); }