//加载完毕回调 void count_load() { if (load_error_flag == false) { if (load_list[load_count].type != "TEMP") { PublicClass.Asset_loaded_list.Add(load_list[load_count]); } } else { //资源加载出错,放弃继续 SetOperaToLoop(); UnityEngine.Debug.Log("load error " + load_list[load_count].name); Unity_Tools.ui_return_to_platform("alert", "资源加载错误,请重试。"); return; } load_count++; show_progress.current_progress = (float)load_count / (float)load_length; if (load_list.Count > load_count) { timer = 0; StartCoroutine(LoadPrefabModel(PublicClass.filePath + load_list[load_count].name, Vesal_DirFiles.remove_name_suffix(load_list[load_count].name), count_load)); } if (load_count == load_length) { DebugLog.DebugLogInfo("加载完毕 获取平台参数:"); //后台加载完成后,进入场景分发器,异步加载多个场景 OperaStatus = AppOperState.Apprun; } }
//下载错误 void download_error(Exception e) { vesal_log.vesal_write_log("下载文件异常" + e.Message); vesal_log.vesal_write_log("下载文件异常" + e.StackTrace); SetOperaToLoop(); Unity_Tools.ui_return_to_platform("alert", "网络下载异常,请重试。"); }
private void DownLoadRemoteData() { Unity_Tools.StarTime("获取远程数据计时-------"); //判断有网时操作 if (!MainConfig.isFetchDb) { PublicClass.server_ip = vesal_network.Vesal_Network.get_ipfromlist(PublicClass.get_server_interface); PublicClass.server_test_url = PublicClass.server_ip + PublicClass.fix_server_interface; PublicClass.data_list_count = PublicClass.tableCount; PublicClass.DataManagerStatus = DataIntState.GoABdownload; } PublicClass.online_mode = MainConfig.isOnline; if (PublicClass.online_mode && vesal_network.Vesal_Network.get_network_is_acitve() & PPTGlobal.PPTEnv != PPTGlobal.PPTEnvironment.PPTPlayer) { try { PublicClass.server_ip = vesal_network.Vesal_Network.get_ipfromlist(PublicClass.get_server_interface); if (PublicClass.server_ip != "") { PublicClass.server_test_url = PublicClass.server_ip + PublicClass.fix_server_interface; DebugLog.DebugLogInfo("unity --------------------在线启动"); StartCoroutine(StartUpdateTable()); PublicClass.DataManagerStatus = DataIntState.FetchingDb; PublicClass.low_res_ablist = ""; } else { DebugLog.DebugLogInfo("unity --------------------离线启动"); PublicClass.online_mode = false; PublicClass.data_list_count = PublicClass.tableCount; PublicClass.DataManagerStatus = DataIntState.GoABdownload; } } catch { DebugLog.DebugLogInfo("unity --------------------离线启动"); } } else { PublicClass.online_mode = false; DebugLog.DebugLogInfo("unity --------------------离线启动"); PublicClass.data_list_count = PublicClass.tableCount; PublicClass.DataManagerStatus = DataIntState.GoABdownload; } }
private void Update() { switch (PublicClass.DataManagerStatus) { case DataIntState.FetchingDb: if (PublicClass.data_list_count < PublicClass.tableCount) { showProgress.current_progress = (float)PublicClass.data_list_count / PublicClass.tableCount; } else { PublicClass.DataManagerStatus = DataIntState.GoABdownload; } break; case DataIntState.GoABdownload: Unity_Tools.CanculateLoadTime(); // DebugLog.DebugLogInfo("本地数据地址 "+PublicClass.filePath); DebugLog.DebugLogInfo("数据加载完成=============================================="); AnalysisResourceList(); //加载模型资源 //PublicClass.data_list_count = 0; break; case DataIntState.Downloading: showProgress.current_progress = (http.progress + ndr) / Ready_Download_list.Count; Mathf.Clamp(showProgress.current_progress, 0f, 1f); break; case DataIntState.Update: showProgress.Set_Progress("正在更新补丁数据..."); PublicClass.DataManagerStatus = DataIntState.Updating; DataUpdating(); break; case DataIntState.HotFix: showProgress.Set_Progress("正在更新补丁数据..."); PublicClass.DataManagerStatus = DataIntState.HotFixing; // hotFixControll.loads(); break; case DataIntState.GoNextScence: PublicTools.Model_AB_dic_update(); ManageModel.Instance.load_assets_A(Download_list); PublicClass.DataManagerStatus = DataIntState.Null; break; default: break; } }
//异步加载assetbundle资源列表 public void load_assets_A(Action load_complete = null) { Unity_Tools.StarTime("获取远程数据计时-------"); load_length = 0; load_count = 0; load_length = load_list.Count; DebugLog.DebugLogInfo("--------------------加载模型长度:" + load_length); for (int i = 0; i < load_list.Count; i++) { DebugLog.DebugLogInfo("--------------------: " + load_list[i].name); } StartCoroutine(LoadPrefabModel(PublicClass.filePath + load_list[0].name, Vesal_DirFiles.remove_name_suffix(load_list[0].name), count_load)); }
//返回平台 public void ExitProgram() { DebugLog.DebugLogInfo("back SceneSwitch"); try { DestroyImmediate(GameObject.Find("temp_parent")); ManageModel.Instance.Destory_Transform_temp_child(); } catch (Exception e) { DebugLog.DebugLogInfo(e.Message); DebugLog.DebugLogInfo(e.StackTrace); } Unity_Tools.ui_return_to_platform(); }
private void Download_error(Exception e) { //下载失败,最多尝试3次 if (download_trys < PublicClass.MaxTryDownloadNums) { http = new HttpDownLoad(); DownSwitch(); } else { //彻底退出 Unity_Tools.ui_return_to_platform(); Application.Quit(); } download_trys++; }
//下载切换 void DownSwitch() { string tmpName = Ready_Download_list[ndr].name; string tmpUrl = Ready_Download_list[ndr].url;//+ "?v=" + System.DateTime.Now; string filePath; switch (Ready_Download_list[ndr].type.ToLower()) { case "anim_ab": filePath = PublicClass.Anim_TimelinePath + tmpName; PublicClass.Anim_ABPath = filePath; break; case "ab": filePath = PublicClass.filePath + tmpName; break; case "db": filePath = PublicClass.vesal_db_path + tmpName; break; case "update": filePath = PublicClass.filePath + tmpName; break; case "lua": filePath = PublicClass.filePath + tmpName; Vesal_DirFiles.ClearFolder(PublicClass.xluaPath); break; default: filePath = PublicClass.filePath + tmpName; break; } Debug.Log("当前下载资源:" + tmpName + " 路径:" + tmpUrl + "version " + Ready_Download_list[ndr].version); Vesal_DirFiles.DelFile(filePath); if (!http.DownLoad(tmpUrl, filePath, Download, Download_error)) { Unity_Tools.ui_return_to_platform(); Application.Quit(); //下载过程中,连接断开,重连失败 } }
public void exitSceneSwitch() { timer = 0; try { if (http != null) { http.Close(); } } catch (Exception e) { UnityEngine.Debug.Log(e.Message); UnityEngine.Debug.Log(e.StackTrace); } Unity_Tools.clear_message_from_platform(); Unity_Tools.ui_return_to_platform(); }
public void ExitProgram() { showMode.closeSence(); timelineControll.close(); Interaction.AnimationRotateY = 1; DebugLog.DebugLogInfo("back SceneSwitch"); try { ManageModel.Instance.Destory_Transform_temp_child(); DestroyImmediate(GameObject.Find("temp_parent")); } catch (Exception e) { DebugLog.DebugLogInfo(e.Message); DebugLog.DebugLogInfo(e.StackTrace); } Unity_Tools.ui_return_sceneSwitch(); }
/// <summary> /// 确认、取消按钮 /// </summary> /// <param name="isConfirm">是否是确认按钮</param> public void ExitChoice(bool isConfirm) { if (isConfirm) //如果是确认按钮 { Debug.Log("Application"); Unity_Tools.ui_return_to_platform(); SceneManager.LoadScene("SceneSwitch"); //退出程序 } else //如果是取消按钮 { Time.timeScale = 1; //解冻时间 quitAppPanel.SetActive(false); //关闭退出界面 } }
void Update() { //UnityEngine.Debug.Log(OperaStatus); if (OperaStatus != AppOperState.Loop) { timer = 0; } switch (OperaStatus) { case AppOperState.Loop: timer++; #if UNITY_EDITOR #elif UNITY_IOS string message = Unity_Tools.get_message_from_platform_for_ios(); if (message != "") { DebugLog.DebugLogInfo("-------------------------------get_message---------------------------------------"); Get_app(message); Unity_Tools.clear_message_from_platform_for_ios(); } if (timer > 60) { Unity_Tools.ui_return_to_platform(); timer = 0; } #elif UNITY_ANDROID string message = Unity_Tools.get_message_from_platform_for_android(); if (message != "") { DebugLog.DebugLogInfo("-------------------------------get_message---------------------------------------"); Get_app(message); Unity_Tools.clear_message_from_platform_for_android(); } if (timer > 60) { Unity_Tools.ui_return_to_platform(); timer = 0; } #endif break; case AppOperState.Apprun: DebugLog.DebugLogInfo(" 资源完备加载 加载场景 " + this_app.app_type); UnityEngine.Debug.Log(" 资源完备加载 加载场景 " + this_app.app_type); switch (PublicClass.app.app_type) { case "model": //SetOperaToRuning(); #if UNITY_EDITOR || UNITY_STANDALONE_WIN if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.plugin) { Load_Scene("UI4_PptPlugin"); } else { show_progress.CloseBtn(true); Load_Scene("UI3"); } #elif UNITY_IOS || UNITY_ANDROID Load_Scene("UI2", false); #endif //show_progress.StopLoad(); // Load_Scene("sign"); break; case "sign": show_progress.CloseBtn(true); Load_Scene("UI_sign", false); break; case "sign_ssp": case "sign_new": case "sign_acu": show_progress.CloseBtn(true); Load_Scene("UI_sign_all"); // Load_Scene("sign"); break; case "ppt": Load_Scene("ppt"); break; case "microlesson": show_progress.CloseBtn(false); Load_Scene("WeiKePlayer"); break; case "game": show_progress.CloseBtn(false); Load_Scene("Block_UI"); break; case "exam": Load_Scene("totalScence"); break; case "medical": Load_Scene("Medical", true); break; case "animation": Load_Scene("MotorAnatomy", true); break; case "acu": Load_Scene("NewAcu", true); break; case "cfd": Load_Scene("CFD", true); break; default: break; } //SetOperaToRuning(); break; case AppOperState.LoadScene: if (show_progress != null) { show_progress.current_progress = _async.progress; } //vesal_log.vesal_write_log("load scenec" + _async.progress); break; case AppOperState.Appruning: //if (show_progress.current_progress <= 0.8f) if (_async != null && _async.progress >= 0.85f && _async.allowSceneActivation == false) { _async.allowSceneActivation = true; } break; case AppOperState.UpdateData: show_progress.Set_Progress("系统正在为下载后首次运行准备数据,请稍等..."); update_app_fix(); OperaStatus = AppOperState.UpdataDating; break; case AppOperState.Downloading: if (http.progress <= 1.0f) { show_progress.current_progress = http.progress; } break; case AppOperState.AssetLoad: UnityEngine.Debug.Log("模型正在加载中..." + PublicClass.app.app_type); show_progress.Set_Progress("模型正在加载中...", Call); switch (PublicClass.app.app_type) { case "acu": case "model": // OperaStatus = AppOperState.Apprun; // break; case "sign": case "sign_ssp": case "sign_new": case "sign_acu": case "ppt": case "microlesson": case "game": case "exam": UnityEngine.Debug.Log("cacaulte_load_list();"); cacaulte_load_list(); if (load_list.Count() == 0) { UnityEngine.Debug.Log("OperaStatus = AppOperState.Apprun;"); OperaStatus = AppOperState.Apprun; } else { OperaStatus = AppOperState.AssetLoading; UnityEngine.Debug.Log("OperaStatus = AppOperState.AssetLoading;"); load_assets_A(count_load); } break; case "cfd": OperaStatus = AppOperState.Apprun; //cacaulte_load_list(); if (load_list.Count() == 0) { UnityEngine.Debug.Log("OperaStatus = AppOperState.Apprun;"); OperaStatus = AppOperState.Apprun; } else { OperaStatus = AppOperState.AssetLoading; UnityEngine.Debug.Log("OperaStatus = AppOperState.AssetLoading;"); load_assets_A(count_load); } break; default: break; } break; case AppOperState.UnZip: OperaStatus = AppOperState.UnZiping; if (File.Exists(downloadFilePath)) { StartCoroutine(Vesal_DirFiles.UnZipAsync(downloadFilePath, targetSourcePath + "/", unzipProgress, true)); //StartCoroutine(StartUnzip(downloadFilePath, targetSourcePath)); } else { OperaStatus = AppOperState.AssetLoad; } break; default: break; } }
public static void SetOperaToLoop() { OperaStatus = AppOperState.Loop; Unity_Tools.set_value_to_platform("Unity_state", "Loop"); Unity_Tools.send_message_to_platform("setUnityState", "Loop"); }
public static void SetOperaToRuning() { OperaStatus = AppOperState.Appruning; Unity_Tools.set_value_to_platform("Unity_state", "Run"); Unity_Tools.send_message_to_platform("setUnityState", "Run"); }
List <Download_Vesal_info> load_list;//异步加载assetbundle资源列表 public void load_assets_A(List <Download_Vesal_info> targetList, Action load_complete = null) { if (PublicClass.id_model_dic == null) { PublicClass.id_model_dic = new Dictionary <string, int>(); } load_list = new List <Download_Vesal_info>(); foreach (Download_Vesal_info temp in targetList) { if ((temp.type == null) || (temp.type.ToUpper() == "") || (temp.type.ToUpper() == "AB")) { load_list.Add(temp); PublicClass.total_load_list.Add(temp); } } //DebugLog.DebugLogInfo("--------------------可以加载模型长度:" + PublicClass.total_load_list.Count); //foreach (Download_Vesal_info temp in PublicClass.total_load_list) //{ // DebugLog.DebugLogInfo("total list:" + temp.name); //} //去掉多余的加载项 int max = load_list.Count; for (int k = PublicClass.int_load_AB_nums; k < max; k++) { load_list.RemoveAt(PublicClass.int_load_AB_nums); } Unity_Tools.StarTime("获取远程数据计时-------"); progress.Set_Progress("模型正在加载中...", Call); length = 0; count = 0; length = load_list.Count; DebugLog.DebugLogInfo("--------------------加载模型长度:" + length); ////加载公共库异常处理 //if (load_list.Count == 0) //{ // progress.Set_Progress("加载数据错误...", Call); //} //这是在未PPTPlayer 播放时,启动时指定vsl文件而给与解压 if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer || PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.WeiKePlayer) { isUnzipDown = true; string[] CommandLineArgs = Environment.GetCommandLineArgs(); for (int i = 0; i < CommandLineArgs.Length; i++) { string tmpStr = CommandLineArgs[i]; //tmpStr = "C:\\vesalplayer\\WK0000001_5.vsl"; Debug.Log("GetCommandLineArgs::" + tmpStr); vesal_log.vesal_write_log("GetCommandLineArgs::" + tmpStr); if (tmpStr.Contains(".vsl") || tmpStr.Contains(".VSL")) { Debug.Log("GetCommandLineArgs::" + tmpStr); //SelectFile(tmpStr); PPTHomePageController.TempFilePath = PPTHomePageController.getTempPath(); vesal_log.vesal_write_log("PPTHomePageController.TempFilePath " + PPTHomePageController.TempFilePath); StartCoroutine(Vesal_DirFiles.UnZipAsync(tmpStr, PPTHomePageController.TempFilePath, ManagerModelUnzipCall, true)); PPTResourcePool.isSkipUnzip = true; isUnzipDown = false; PPTHomePageController.currentFilePath = tmpStr; break; } } } if (load_list.Count > 0) { //设置加载标记 start_load_model = true; timer = 0; // progress = GameObject.Find("LoadingCanvas").transform.GetComponent<ShowProgress>(); StartCoroutine(LoadPrefabModel(PublicClass.filePath + load_list[0].name, Vesal_DirFiles.remove_name_suffix(load_list[0].name), count_load)); } else { start_load_model = false; this.ReadModelInfo(); if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.demo_pc) { SceneManager.LoadScene("SceneSwitchInteral"); } else { SceneManager.LoadScene("SceneSwitch"); } } }
void Start() { Unity_Tools.Get_scene_instance <ShowProgress>("LoadingCanvas_pc").CloseProgress(); }
void Start() { OperaStatus = AppOperState.Init; DebugLog.DebugLogInfo("-------------------------------进入场景分发器---------------------------------------"); //创建资源文件夹 Create_assets_path(); if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer) { SceneManager.LoadScene("WeiKePlayer"); return; } show_progress = Unity_Tools.Get_scene_instance <ShowProgress>("LoadingCanvas_pc"); #if UNITY_EDITOR if (firstTest) { //StartCoroutine(App_tool.testMethod("游戏", "2", "game", "GA0101001", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001// // StartCoroutine(App_tool.testMethod("经络穴位", "24", "acu", "AA0100012N", Get_app)); //StartCoroutine(App_tool.testMethod_acu("acu", "AA0100000N", Get_app)); //StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", "RA0801001", Get_app)); //Get_app(App_tool.testMethod()); //StartCoroutine(App_tool.testMethod_wk_lz("微课课程", "13", "microlesson", "WK0000001", Get_app)); //StartCoroutine(App_tool.testMethod("肌肉动画", "29", "equip_drill", "MAO10001", Get_app)); //StartCoroutine(App_tool.testMethod("测验练习", "exam", "qa001", Get_app)); //StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0A01001", Get_app));//SA0201007//SA0202010 // StartCoroutine(App_tool.testMethod("人体构造", "2", "animation", "DA0100039", Get_app)); // StartCoroutine(App_tool.testMethod("微课课程", "2", "microlesson", "HMFWK001", Get_app));//HMFWK002 // StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", "RA0801001", Get_app)); //StartCoroutine(App_tool.testMethod("人体构造", "2", "sign_ssp", "SA0C01007", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001 // StartCoroutine(App_tool.testMethod("经络穴位", "24", "sign_acu", "AA0100002", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001// //StartCoroutine(App_tool.testMethod("人体构造", "2", "sign", "SA0604002", Get_app));//SA0903001//SA0903005//SA0903006//SA0903007 Get_app(App_tool.testMethod_signnew("sign_new", "SA090C003", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001//SA0C02000//SA0C04002// //StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0000000", Get_app));//SA0101047//SA0000000//RA0100001//SA0801002 firstTest = false; } else { firstTest = true; // StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", "RA0801004", Get_app)); // StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0801003", Get_app)); // StartCoroutine(App_tool.testMethod("人体构造", "model", "SA0101047", Get_app));//SA0101047//SA0000000//RA0100001 //StartCoroutine(App_tool.testMethod("经络穴位", "24", "sign_acu", "AA0100000", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001// // StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0000000", Get_app)); // StartCoroutine(App_tool.testMethod("微课课程", "2", "microlesson", "HMFWK001", Get_app));//HMFWK002 // StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0101047", Get_app));//SA0103043 // StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0101047", Get_app)); //StartCoroutine(App_tool.testMethod("人体构造", "2", "animation", "DA0100050", Get_app)); // StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", get_id_list(), Get_app)); // StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", "RA0801001", Get_app)); // StartCoroutine(App_tool.testMethod("测验练习", "2", "exam", "qa001", Get_app)); // StartCoroutine(App_tool.testMethod("经络穴位", "24", "sign_acu", "AA0100005", Get_app)); //StartCoroutine(App_tool.testMethod("经络穴位", "24", "acu", "AA0100009N", Get_app)); } #elif UNITY_ANDROID show_progress = Unity_Tools.Get_scene_instance <ShowProgress>("LoadingCanvas"); #elif UNITY_STANDALONE_WIN show_progress = Unity_Tools.Get_scene_instance <ShowProgress>("LoadingCanvas_pc"); if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.plugin) { if (PublicClass.app != null) { Get_app(PublicClass.app); } } else { if (!PublicClass.is_enter_server_control) { InternalSocketMananger.instance.HideUnityWidows(); DebugLog.DebugLogInfo("HideUnityWidows"); } } #endif if (PublicClass.app == null) { SetOperaToLoop(); } }
//加载完毕回调 void count_load() { print(load_list.Count + " ---------- count"); if (load_error_flag == false) { PublicClass.Asset_loaded_list.Add(load_list[count]); } count++; progress.current_progress = (float)count / (float)length; if (load_list.Count > count) { timer = 0; StartCoroutine(LoadPrefabModel(PublicClass.filePath + load_list[count].name, Vesal_DirFiles.remove_name_suffix(load_list[count].name), count_load)); } if (count == length) { #if UNITY_EDITOR //Debug.LogError(LoadResult); #endif start_load_model = false; this.ReadModelInfo(); PublicClass.Transform_parent.gameObject.SetActive(false); ReadModel(PublicClass.Transform_parent); #if UNITY_ANDROID // DebugLog.DebugLogInfo("返回平台!"); Unity_Tools.ui_return_to_platform(); #endif isLoadAbDown = true; if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer || PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.WeiKePlayer) { //if (PPTResourcePool.isSkipUnzip == true) //{ // isLoadAbDown = true; //} if (isLoadAbDown && isUnzipDown) { isLoadAbDown = false; if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.demo_pc) { SceneManager.LoadScene("SceneSwitchInteral"); } else { SceneManager.LoadScene("SceneSwitch"); } } return; } if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.demo_pc) { SceneManager.LoadScene("SceneSwitchInteral"); } else { SceneManager.LoadScene("SceneSwitch"); } } }