//加载完毕回调 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", "网络下载异常,请重试。"); }
//返回平台 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(); }
/// <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; } }
//加载完毕回调 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"); } } }