public UI Create() { try { ResourcesComponent res = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); res.LoadBundle(UIType.UILogin.StringToAB()); GameObject bundleGameObject = res.GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin) as GameObject; GameObject go = UnityEngine.Object.Instantiate(bundleGameObject); go.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UILogin, go, false); var com = ui.AddComponent <UILoginComponent>(); adapter = ui.AddComponent <UILoginAdapterComponent>(); adapter.Init(com); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public UI Create(Scene scene, string type, GameObject gameObject) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject room = UnityEngine.Object.Instantiate(bundleGameObject); room.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(room); ui.AddComponent <UIRoomComponent>(); ui.AddComponent <GamerComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public UI Create(Scene scene, string type, GameObject parent) { //TODO Log.Debug("FairyGUI.UIPackage.AddPackage(Bag);"); FairyGUI.UIPackage.AddPackage("FGUI/Bag"); UI ui = ComponentFactory.Create <UI, GameObject>(null); ui.AddComponent <FGUITestComponent>(); return(ui); }
public void SetInfo(FriendRoomRecordInfo info, int id) { this.info = info; this.index = id; AccountAllScore(); MyAccountAllScore(); int allScore = 0; List <int> myList = MyScore(PlayerInfoComponent.Instance.uid); if (myList != null) { for (int i = 0; i < myList.Count; ++i) { allScore += myList[i]; } } if (allScore >= 0) { ScoreTxt.text = "+" + allScore.ToString(); } else { ScoreTxt.text = allScore.ToString(); } Result.sprite = CommonUtil.getSpriteByBundle("image_main", allScore >= 0 ? "win" : "fail"); RoomIdTxt.text = info.roomNum.ToString(); TimeTxt.text = info.time.ToString(); GameObject obj = null; int index = 0; foreach (var score in scoreDic) { if (index < objList.Count) { obj = objList[index]; } else { obj = GameObject.Instantiate(item, AccountGrid.transform); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIFriendRoomTxtComponent>(); uiList.Add(ui); objList.Add(obj); } uiList[index].GetComponent <UIFriendRoomTxtComponent>().SetInfo(score.Key, score.Value); index++; } }
public UI Create(Scene scene, string type, GameObject parent) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); resourcesComponent.LoadBundle($"{CardHelper.ATLAS_NAME}.unity3d"); resourcesComponent.LoadBundle($"{HandCardsComponent.HANDCARD_NAME}.unity3d"); resourcesComponent.LoadBundle($"{HandCardsComponent.PLAYCARD_NAME}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject room = UnityEngine.Object.Instantiate(bundleGameObject); room.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(room); ui.AddComponent <GamerComponent>(); ui.AddComponent <LandlordsRoomComponent>(); return(ui); } catch (Exception e) { Log.Error(e.ToStr()); return(null); } }
/// <summary> /// 打开点击锁定界面 /// </summary> /// <param name="lockTime"></param> public void SetClickLock(float lockTime = 0.5f) { if (this.UIClickLock == null) { GameObject gameObject = LoadUIAsset(UIType.UIClickLock); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UIClickLock, gameObject, false); this.UIClickLock = ui.AddComponent <UIClickLock>(); Game.Scene.GetComponent <UIComponent>().Add(ui); } this.UIClickLock.OnOpen(lockTime); }
/// <summary> /// 创建邮件列表 /// </summary> public void CreateEmailItemList() { if (emailList.Count <= 0) { SetMoreMailHide(0); } GameObject obj = null; for (int i = 0; i < emailList.Count; ++i) { if (i < emailItemList.Count) { emailItemList[i].SetActive(true); obj = emailItemList[i]; } else { obj = GameObject.Instantiate(emailItem); obj.transform.SetParent(grid.transform); obj.transform.localScale = Vector3.one; obj.transform.name = emailList[i].EId.ToString(); obj.transform.localPosition = Vector3.zero; UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIEmailItemComponent>(); uiList.Add(ui); emailItemList.Add(obj); } if (emailList[i].State == 0) { obj.transform.SetAsFirstSibling(); } try { uiList[i].GetComponent <UIEmailItemComponent>().SetEmailData(emailList[i]); } catch (Exception e) { Log.Error(e); } } emailCountTxt.text = new StringBuilder() .Append(emailList.Count) .Append("/") .Append(50).ToString(); SetMoreMailHide(emailList.Count); }
private UI Create() { UI loginUI = null; try { var resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(UIType.LandlordsLogin.StringToAB()); var bundleGameObject = resourcesComponent.GetAsset(UIType.LandlordsLogin.StringToAB(), UIType.LandlordsLogin) as GameObject; var gameObject = GameObject.Instantiate(bundleGameObject); loginUI = ComponentFactory.Create <UI, string, GameObject>(UIType.LandlordsLogin, gameObject, false); loginUI.AddComponent <LoginComponent>(); } catch (Exception e) { Log.Error(e); } return(loginUI); }
public static UI Create(string type, UI parent, bool isWin) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); GameObject prefab = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject endPanel = UnityEngine.Object.Instantiate(prefab); endPanel.layer = LayerMask.NameToLayer("UI"); UI ui = ComponentFactory.Create <UI, GameObject>(endPanel); parent.Add(ui); ui.GameObject.transform.SetParent(parent.GameObject.transform, false); ui.AddComponent <LandlordsEndComponent, bool>(isWin); return(ui); }
public static UI Create() { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(UIType.UIInitGame.StringToAB()); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UIInitGame.StringToAB(), UIType.UIInitGame); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UIInitGame, gameObject, false); ui.AddComponent <UIInitGameComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static UI Create() { try { AssetRequest assetRequest = Assets.LoadAsset("Assets/Bundles/UI/" + UIType.UIPlayerDie + ".prefab", typeof(GameObject)); GameObject bundleGameObject = assetRequest.asset as GameObject; GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject, AssetRequest>(UIType.UIPlayerDie, gameObject, assetRequest, false); ui.AddComponent <UIPlayerDieComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static UI Create(G2C_CowCowLoginGate data) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(UICowCowAB.CowCow_Prefabs); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UICowCowAB.CowCow_Prefabs, UICowCowType.CowCowLobby); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject>(UICowCowType.CowCowLobby, gameObject, false); ui.AddComponent <UICowCowLobbyComponent, G2C_CowCowLoginGate>(data); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static UI Create() { try { ResourcesComponent rc = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); rc.LoadBundle(UIType.TestUILogin.StringToAB()); GameObject go = (GameObject)rc.GetAsset(UIType.TestUILogin.StringToAB(), UIType.TestUILogin); GameObject gameObject = UnityEngine.Object.Instantiate(go); //创建对象 UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.TestUILogin, gameObject); ui.AddComponent <TestUILoginComponent>(); //给创建的对象加入这个组件功能 return(ui); } catch (Exception e) { Log.Error("创建UI异常:" + e.Message); return(null); } }
/// <summary> /// 打开跑马灯 /// </summary> /// <param name="message"></param> public void ShowNoticeUI(string message = "", NoticeData data = null) { GameObject gameObject = LoadUIAsset(UIType.UIScrollNoticePanel); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UIScrollNoticePanel, gameObject, false); var pmd = ui.AddComponent <ScrollNoticeComponent>(); Game.Scene.GetComponent <UIComponent>().Add(ui); if (data == null) { data = new NoticeData(); } data.mes = message; pmd.OnOpen(data); }
public UI Create(Scene scene, UIType type, GameObject gameObject) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); GameObject bundleGameObject = resourcesComponent.GetAsset <GameObject>($"{type}.unity3d", $"{type}"); GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject); lobby.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(lobby); ui.AddComponent <UILobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e.ToStr()); return(null); } }
public UI Create(Scene scene, string type, GameObject gameobject) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject go = UnityEngine.Object.Instantiate(bundleGameObject); string content = GameUtil.GetTip(); go.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(go); ui.AddComponent <UIFriendRoomCommonTipComponent, String>(content); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static UI Create(Scene scene, string type, GameObject gameObject, UIView uiView) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.AwayPrefixLoadBundle($"{type}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.AwayPrefixGetAsset($"{type}.unity3d", $"{type}"); GameObject go = UnityEngine.Object.Instantiate(bundleGameObject); go.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, string, GameObject>(type, go); ui.AddComponent(uiView); //resourcesComponent.AwayPrefixUnloadBundle($"{type}.unity3d"); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static UI Create() { try { ResourcesComponent res = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); res.LoadBundle(GlobalsUIAB.Globals_Prefabs); GameObject ab = (GameObject)res.GetAsset(GlobalsUIAB.Globals_Prefabs, GlobalsUIType.UIPopupsCanvas); GameObject go = UnityEngine.Object.Instantiate(ab); UI ui = ComponentFactory.Create <UI, string, GameObject>(GlobalsUIType.UIPopupsCanvas, go, false); res.UnloadBundle(GlobalsUIAB.Globals_Prefabs); ui.AddComponent <UIPopupsComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
private void CreateItems() { GameObject obj = null; for (int i = 0; i < friendRoomRecordInfoList.Count; ++i) { if (i < objList.Count) { obj = objList[i]; } else { obj = GameObject.Instantiate(item, UIFriendGrid.transform); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIMyRankItem>(); itemUIList.Add(ui); objList.Add(obj); } itemUIList[i].GetComponent <UIMyRankItem>().SetInfo(friendRoomRecordInfoList[i], i); } }
public static UI Create() { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(UIType.UILobby.StringToAB()); //拿到大厅资源 进行克隆实例 GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); //创建大厅实体->调用UI Awake方法 传递这2个参数 UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UILobby, gameObject, false); //添加UILobbyComponent组件 那么就会调度UILobbyComponent的Awake方法 ui.AddComponent <UILobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
private void CreateItems() { GameObject obj = null; for (int i = 0; i < info.gameList.Count; ++i) { if (i < objList.Count) { obj = objList[i]; } else { obj = GameObject.Instantiate(item, Grid.transform); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIFriendDetailComponent>(); uiList.Add(ui); objList.Add(obj); } uiList[i].GetComponent <UIFriendDetailComponent>().SetInfo(info.gameList[i].time, info.roomNum, info.gameList[i], i + 1); } }
public static UI Create(G2C_CowCowJoinGameRoomGate room) { try { ResourcesComponent rc = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); rc.LoadBundle(UICowCowAB.CowCow_Prefabs); GameObject ab = (GameObject)rc.GetAsset(UICowCowAB.CowCow_Prefabs, UICowCowType.CowCowGameRoom); GameObject gameObject = UnityEngine.Object.Instantiate(ab); UI ui = ComponentFactory.Create <UI, string, GameObject>(UICowCowType.CowCowGameRoom, gameObject); ui.AddComponent <UICowCow_GameRoomComponent>(); //加入游戏房间组件 ui.GetComponent <UICowCow_GameRoomComponent>().Init(room.GameName, room.Bureau, room.RuleBit, room.RoomID, room.People, room.CurBureau); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
private void CreateItemList(List <Bag> itemList) { GameObject obj = null; if (itemList.Count <= 0) { SetMoreHide(0); } for (int i = 0; i < itemList.Count; ++i) { if (i < bagItemList.Count) { bagItemList[i].SetActive(true); obj = bagItemList[i]; } else { obj = GameObject.Instantiate(bagItem); obj.transform.SetParent(grid.transform); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; bagItemList.Add(obj); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIBagItemComponent>(); uiList.Add(ui); } if (item != null && IsCurPropUseUp()) { SetItemInfo(item); } else { SetItemInfo(itemList[0]); } uiList[i].GetComponent <UIBagItemComponent>().SetItemInfo(itemList[i], i + 1); } SetMoreHide(itemList.Count); }
public static async ETVoid CreateJoystickUI(ETTaskCompletionSource <UI> tcs) { try { AssetRequest assetRequest = Assets.LoadAssetAsync("Assets/Bundles/UI/" + UIType.UIJoystick + ".prefab", typeof(GameObject)); //创建一个角色的3D物体 GameObject bundleGameObject = await ETModel.Game.Scene.GetComponent <ResourcesAsyncComponent>().LoadAssetAsync <GameObject>(assetRequest); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject, AssetRequest>(UIType.UIJoystick, gameObject, assetRequest, false); VariableJoystickComponent variableJoystick = ui.AddComponent <VariableJoystickComponent>(); variableJoystick.joystickType = JoystickType.Floating; tcs.SetResult(ui); } catch (Exception e) { Log.Error(e); tcs.SetResult(null); } }
/// <summary> /// 创建房间Item /// </summary> private void CreateRoomItemss(List <FriendRoomInfo> roomInfos) { GameObject obj = null; for (int i = 0; i < roomInfos.Count; ++i) { if (i < roomItems.Count) { obj = roomItems[i]; } else { obj = GameObject.Instantiate(roomItem, FriendGrid.transform); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; roomItems.Add(obj); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIFriendRoomItemComponent>(); uiFList.Add(ui); } uiFList[i].GetComponent <UIFriendRoomItemComponent>().SetItemInfo(roomInfos[i]); } }
//---------------对外接口------------------------------ /* 添加一个警告窗口 并 置顶 * param: * strWord:窗口文本 * cb:按钮事件 * strBtn:按钮文本 */ public void CreateAlertWin( string strWord, AlertCallBack cb, string strBtn = "好的" ) { GameObject g = UnityEngine.Object.Instantiate(prefabAlert_); g.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(g); UIAlertWin win = ui.AddComponent <UIAlertWin>(); GameObjectUtil.SetParentToChild(alertsRoot_, ui.GameObject, false); GameObjectUtil.SetZ(ui.GameObject, ZORDER_ALERT); win.SetTextContent(strWord); win.SetCheckCb(cb); win.SetCheckBtnText(strBtn); win.SetCloseCallBack(closeWin); wins_.Add(ui); checkOpenBg(); }
/// <summary> /// 文字提示 /// </summary> /// <param name="message"></param> /// <param name="showTime"></param> public async void ShowTips(string message, int showTime = 1) { if (isAct) { return; } GameObject gameObject = LoadUIAsset(UIType.UITip); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UITip, gameObject, false); var tip = ui.AddComponent <UITipCpt>(); Game.Scene.GetComponent <UIComponent>().Add(ui); isAct = true; var _tra = tip.GetParent <UI>().GameObject.transform; _tra.Find("Text").GetComponent <Text>().text = message; _tra.localPosition = new Vector3(0, 300, 0); tipTweener = _tra.DOLocalMoveY(0, 0.3f); tipTweener.Restart(); await Task.Delay(showTime * 1000); _tra.DOLocalMoveY(300, 0.3f); await Task.Delay(300); Game.Scene.GetComponent <UIComponent>().Remove(UIType.UITip); isAct = false; }
public static UI Create() { try { string uiType = UIType.UIMain; //1.获取资源组件 ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); //加载bundle resourcesComponent.LoadBundle(uiType.StringToAB()); //将bundle加载成obj GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(uiType.StringToAB(), uiType); //实例化 GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject>(uiType, gameObject, false); ui.AddComponent <UIMainComponent>(); return(ui); } catch (System.Exception e) { Log.Error(e); return(null); } }
private void CreateTaskItem(List <TaskInfo> taskInfoList) { GameObject obj = null; for (int i = 0; i < taskInfoList.Count; ++i) { if (i < taskItemList.Count) { obj = taskItemList[i]; } else { obj = GameObject.Instantiate(taskItem); obj.transform.SetParent(grid.transform); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UITaskItemComponent>(); taskItemList.Add(obj); uiList.Add(ui); } uiList[i].GetComponent <UITaskItemComponent>().SetTaskItemInfo(taskInfoList[i]); } }
/// <summary> /// 显示战绩榜 /// </summary> private void ShowGameRank() { //Grid.transform.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1); GameObject obj = null; SetUIState(1, 0); for (int i = 0; i < gameRankList.Count; ++i) { if (i < gameItemList.Count) { gameItemList[i].SetActive(true); obj = gameItemList[i]; } else { obj = GameObject.Instantiate(RankItem); obj.transform.SetParent(Grid.transform); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; gameItemList.Add(obj); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIRankItemComponent>(); gameUiList.Add(ui); if (i >= ownGame) { gameUiList[i].GetComponent <UIRankItemComponent>().SetGameItem(gameRankList[i], i + 1); } else { gameUiList[i].GetComponent <UIRankItemComponent>().SetGameItem(gameRankList[i], i); } } } SetMoreHide(gameRankList.Count, gameItemList); }