//-------------------------------------------------------- // 内部调用 //-------------------------------------------------------- IEnumerator WaitActorLoad() { while (CreateActorScene.Instance == null || CreateActorScene.Instance.LoadFinish == false || CreateActorScene.Instance.TimelinesIsLoadFinished == false) { yield return(null); } var isAuditAndIos = AuditManager.Instance.AuditAndIOS(); if (!isAuditAndIos || (isAuditAndIos && !SDKHelper.GetSwitchModel())) { var preload_infos = DBPreloadInfo.Instance.PreloadInfos; if (preload_infos.Count > 0) { mPreloadAssetResource.Clear(); foreach (var info in preload_infos) { var object_asset = new AssetResource(); mPreloadAssetResource.Add(object_asset); MainGame.HeartBehavior.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_asset("Assets/" + info.asset_path, typeof(UnityEngine.Object), object_asset)); } float star_wait_time = Time.unscaledTime; // 等待所有资源加载完毕 while (true) { // 最多等待20s if (Time.unscaledTime - star_wait_time > 20.0f) { Debug.LogError("WaitActorLoad: wait preload asset for long time"); break; } bool all_loaded = true; foreach (var info in mPreloadAssetResource) { if (info.asset_ == null) { all_loaded = false; break; } } if (all_loaded) { break; } else { yield return(null); } } } } if (AuditManager.Instance.AuditAndIOS() && SDKHelper.GetSwitchModel()) { GameObjectControl control = Game.Instance.GameObjectControl; if (control != null) { if (control.scene != null && control.uiPanel != null) { control.scene.SetActive(!AuditManager.Instance.Open); control.uiPanel.SetActive(AuditManager.Instance.Open); } } } //int[] actorList = new int[] { 2, 1, 3 }; if (AuditManager.Instance.AuditAndIOS()) { List <uint> actorList = SDKHelper.GetRoleList(); if (actorList != null && actorList.Count >= 1) { mDefaultSelectIndex = (int)actorList[0]; } } OnClickActorBtn((uint)mDefaultSelectIndex); // 等待一帧才隐藏loading界面,避免播放剧情前穿帮 mHideLoadingBKCoroutine = MainGame.HeartBehavior.StartCoroutine(EndFrameHideLoadingBK()); }
protected override void InitUI() { base.InitUI(); mEnterGameButton = FindChild("EnterGameButton").GetComponent <Button>(); mExitButton = FindChild("ExitButton").GetComponent <Button>(); mGenerateNameButton = FindChild("GenerateNameButton").GetComponent <Button>(); mNameInputField = FindChild("NameInputField").GetComponent <InputField>(); mVocationDesc = FindChild("VocationDesc").transform; mRightButtom = FindChild("RightButtom"); mRight = FindChild("Right"); mHealthTips = FindChild("HealthTips"); mHealthTips.SetActive(false); mCreateNewRoleButton = FindChild("CreateNewRoleButton").GetComponent <Button>(); mCreateNewRoleButton.gameObject.SetActive(false); // 获取最大可创建角色数量 var role_ids = GameConstHelper.GetUintList("GAME_AVAILABLE_ROLE_ID"); mActorNum = role_ids.Count; // 获取创角按钮 mActorButtons.Clear(); if (AuditManager.Instance.AuditAndIOS()) { for (int i = 0; i < mActorNum; ++i) { var btn_game_object = FindChild(string.Format("VocationButton{0}", i + 1)); if (btn_game_object != null) { btn_game_object.gameObject.SetActive(false); } } //int[] actorList = new int[] { 2, 1 ,3 }; List <uint> actorList = SDKHelper.GetRoleList(); if (actorList != null) { bool isShowActorBtn = actorList.Count > 1; for (int i = 0; i < actorList.Count; i++) { int career = (int)actorList[i]; var btn_game_object = FindChild(string.Format("VocationButton{0}", career)); if (btn_game_object != null) { btn_game_object.gameObject.SetActive(isShowActorBtn); btn_game_object.transform.Find("CheckMask").gameObject.SetActive(false); btn_game_object.transform.Find("Background").gameObject.SetActive(true); mActorButtons.Add((uint)career, btn_game_object.GetComponent <Button>()); } } } } else { for (int i = 0; i < mActorNum; ++i) { var btn_game_object = FindChild(string.Format("VocationButton{0}", i + 1)); if (btn_game_object != null) { mActorButtons.Add((uint)(i + 1), btn_game_object.GetComponent <Button>()); } } } mEnterGameButton.onClick.AddListener(OnClickEnterGameBtn); mExitButton.onClick.AddListener(OnClickExitBtn); mGenerateNameButton.onClick.AddListener(OnClickNameBtn); foreach (var kv in mActorButtons) { var btn = kv.Value; if (btn != null) { btn.onClick.AddListener(() => { OnClickActorBtn(kv.Key); }); } } mCreateNewRoleButton.onClick.AddListener(OnClickCreateNewRoleButton); if (AuditManager.Instance.AuditAndIOS() && SDKHelper.GetSwitchModel()) { for (int i = 0; i < 3; i++) { GameObject go = FindChild("ActorPic" + (i + 1).ToString()); if (go != null) { LoadMaJiaImage majia = go.AddComponent <LoadMaJiaImage>(); var picName = string.Format("ActorPic{0}.png", (i + 1)); majia.mPath = ResNameMapping.Instance.GetMappingName(picName); majia.SetFailCallBack(() => { RawImage image = majia.GetComponent <RawImage>(); if (image != null) { image.color = new Color(0, 0, 0, 0); } }); mActorPic.Add(go); } } } Game.GetInstance().SubscribeNetNotify(NetMsg.MSG_CREATE_ROLE, HandleCreateRole); ClientEventMgr.GetInstance().SubscribeClientEvent((int)ClientEvent.CE_RANDNAME_UPDATE, OnRandNameUpdate); }