void ReadCopyList() { string target_file = PublicClass.filePath + "filelist.txt"; StartCoroutine((Vesal_DirFiles.Vesal_FileCopy(PublicClass.fileLocalStreamingPath + "filelist.txt", target_file, () => { copy_list.AddRange(Vesal_DirFiles.ReadFileWithLine(target_file)); DebugLog.DebugLogInfo("copy_list count -----------------:" + copy_list.Count); PublicClass.DataManagerStatus = DataIntState.Init; Vesal_DirFiles.DelFile(target_file); }))); }
void UnZip(string filePath, Action call) { if (File.Exists(filePath)) { StartCoroutine(Vesal_DirFiles.unzipInThread(filePath, Vesal_DirFiles.get_dir_from_full_path(filePath), () => { call(); Vesal_DirFiles.DelFile(filePath); })); } else { call(); } }
//截屏操作 IEnumerator ScreenShotCut() { Vesal_DirFiles.DelFile(PublicClass.filePath + "share.png"); //添加水印,截屏完成后,自动调用分享界面 #if UNITY_EDITOR ScreenCapture.CaptureScreenshot(PublicClass.filePath + "share.png"); yield return(new WaitForSeconds(0.7f)); #else //截屏获取图片 ScreenCapture.CaptureScreenshot("share.png"); //截屏 while (true) { if (!File.Exists(PublicClass.filePath + "share.png")) { yield return(null); } else { break; } } #endif yield return(null); Debug.Log("截屏完成 shot completed"); DrawLinePanel.SetActive(true); ShareUsed.SetActive(false); Debug.Log(PublicClass.filePath + "share.png"); JObject data_obj = new JObject(); data_obj["PicturePath"] = PublicClass.filePath + "share.png"; //UnityMessageManager.Instance.SendMessageToRN(new UnityMessage() //{ // name = "share", // data = data_obj, // callBack = (data) => { DebugLog.DebugLogInfo("message : " + data); } //}); // Logo.gameObject.SetActive(true); // Application.CaptureScreenshot(ScreenshotName); //截屏 // yield return new WaitForSeconds(0.7f); //等待 // Debug.Log("截屏完成"); // Logo.gameObject.SetActive(false); //_text.text = "截屏完成"; //_text.color = new Color(0,0,0,1); //_text.CrossFadeAlpha(0f, 0.3f, true);//淡入 //_text.CrossFadeAlpha(4f, 1f, true);//淡出 }
//下载切换 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(); //下载过程中,连接断开,重连失败 } }
void DownloadFileCompleted(object sender, DownloadFileCompletedArgs eventArgs) { if (eventArgs.State == CompletedState.Succeeded && eventArgs.BytesReceived == eventArgs.BytesTotal) { //download completed vesal_log.vesal_write_log("completed file percent:" + eventArgs.DownloadProgress); vesal_log.vesal_write_log("bytes:" + eventArgs.BytesReceived.ToString() + "::" + eventArgs.BytesTotal); string suffix = Vesal_DirFiles.get_name_suffix(savepath); if (suffix == "assetbundle") { // state = "saveab"; abfile_process(); } else if (suffix.ToLower() == "zip") { // state = "zip"; unzip_process(); } else { File.Move(temppath, savepath); if (succes_method != null) { succes_method(); } } } else { vesal_log.vesal_write_log("download fail:" + eventArgs.DownloadProgress); //download failed Vesal_DirFiles.DelFile(temppath); if (fail_method != null) { fail_method(eventArgs.Error); } } if (fileDownloader != null) { fileDownloader.Dispose(); } }
public bool DownLoad(string downUrl, string savePath, Action callBack = null, Action <Exception> errorCallBack = null, bool NameSubDir = false) { state = "download"; sameNameSubDir = NameSubDir; vesal_log.vesal_write_log("-- download: " + downUrl + savePath); savepath = savePath; temppath = savepath + ".temp"; string suffix = Vesal_DirFiles.get_name_suffix(savepath); if (suffix.ToLower() == "zip") { isZipFile = true; } Vesal_DirFiles.DelFile(temppath); if (callBack != null) { succes_method = callBack; } if (errorCallBack != null) { fail_method = errorCallBack; } try { Uri url = new Uri(downUrl); TimeSpan x = new TimeSpan(0, 0, 8); fileDownloader = new FileDownloader.FileDownloader(); fileDownloader.MaxAttempts = 10; fileDownloader.SafeWaitTimeout = x; fileDownloader.DownloadProgressChanged += DownLoadFileChanged; fileDownloader.DownloadFileCompleted += DownloadFileCompleted; fileDownloader.DownloadFileAsync(url, temppath); vesal_log.vesal_write_log("-- downalod asy started"); } catch { return(false); } return(true); }
public bool unzip_process() { vesal_log.vesal_write_log("--unzip file start "); thread = new Thread(delegate() { string fname = Vesal_DirFiles.get_file_name_from_full_path(savepath).Split('.')[0]; string targetdir; if (!sameNameSubDir) { targetdir = Vesal_DirFiles.get_dir_from_full_path(savepath); // Vesal_DirFiles.UnZipAsync(temppath, targetdir, zip_progress, true); } else { targetdir = Vesal_DirFiles.get_dir_from_full_path(savepath) + fname + "/"; if (!Directory.Exists(targetdir)) { Directory.CreateDirectory(targetdir); } // Vesal_DirFiles.UnZipAsync(temppath, targetdir, zip_progress, true); } StreamReader streamReader = new StreamReader(temppath, Encoding.Default); long sum = streamReader.BaseStream.Length; using (ZipInputStream s = new ZipInputStream(streamReader.BaseStream)) { //File.OpenRead(sourcePath) //s.setEncoding("UTF-8"); ZipEntry theEntry; while ((theEntry = s.GetNextEntry()) != null) { progress = 0.5f + (float)s.Position / sum * 0.5f; theEntry.IsUnicodeText = true; string directoryName = Path.GetDirectoryName(theEntry.Name); //UnityEngine.Debug.Log("aaa:" + theEntry.Name); string fileName = Path.GetFileName(theEntry.Name); // create directory if (directoryName.Length > 0) { Directory.CreateDirectory(targetdir + directoryName); } string filePath = targetdir + theEntry.Name; if (File.Exists(filePath)) { File.Delete(filePath); } if (fileName != String.Empty) { using (FileStream streamWriter = File.Create(filePath)) { int size = 2048; byte[] data = new byte[2048]; while (true) { progress = 0.5f + (float)s.Position / sum * 0.5f; size = s.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { break; } } } } } } Vesal_DirFiles.DelFile(temppath); if (succes_method != null) { succes_method(); } }); //开启子线程 thread.IsBackground = true; thread.Start(); //vesal_log.vesal_write_log("-- unzip thread started"); return(true); }
//本地路径检测下载 void CheckAssetAB(string ab_path, string app_version, bool CancelDownload = false) { DebugLog.DebugLogInfo("本地路径检测下载------------------" + this_app.ab_path); if (this_app.ab_path == "" || this_app.ab_path == null || CancelDownload) { DebugLog.DebugLogInfo("无私有资源:" + this_app.ab_path); DownLoad_complete(); return; } string path = Vesal_DirFiles.get_dir_from_full_path(ab_path); string source_name = Vesal_DirFiles.get_file_name_from_full_path(ab_path); string short_name = Vesal_DirFiles.remove_name_suffix(source_name); string suffix = Vesal_DirFiles.get_name_suffix(source_name); downloadFilePath = path + short_name + "_" + app_version + "." + suffix; targetSourcePath = path + short_name + "_" + app_version; DebugLog.DebugLogInfo("targetSourcePath:" + targetSourcePath); // if (!PublicClass.online_mode) // { // DebugLog.DebugLogInfo("离线模式"); // DebugLog.DebugLogInfo("资源路径:" + path); // DebugLog.DebugLogInfo("short_name " + short_name); // int founded = 0; // DirectoryInfo dif = new DirectoryInfo(path); // FileSystemInfo[] fsis = dif.GetFileSystemInfos(); // for (int i = 0; i < fsis.Length; i++) // { // FileSystemInfo tmp = fsis[i]; // if (tmp.FullName == downloadFilePath || tmp.FullName == targetSourcePath || tmp.FullName.Replace("\\", "/") == targetSourcePath || tmp.FullName.Replace("\\", "/") == downloadFilePath) // { // //PublicClass.app.struct_name = short_name; // PublicClass.app.ab_path = Vesal_DirFiles.get_file_name_from_full_path(tmp.FullName); // PublicClass.app.xml_path = tmp.FullName; // founded = 1; // break; // } // } // if (founded == 0) // { // this_app = null; // PublicClass.app = null; // SetOperaToLoop(); // //发送 //#if UNITY_EDITOR || UNITY_STANDALONE_WIN // if (PPTGlobal.PPTEnv != PPTGlobal.PPTEnvironment.plugin) // { // send_cmd((byte)VESAL_CMD_CODE.MSG_CMD, "hide"); // } //#elif UNITY_IOS // Unity_Tools.clear_message_from_platform_for_ios(); // Unity_Tools.ui_return_to_platform(); //#elif UNITY_ANDROID // Unity_Tools.clear_message_from_platform_for_android(); // Unity_Tools.ui_return_to_platform(); //#else //#endif // return; // } // else // { // DownLoad_complete(); // } // } // else // { DebugLog.DebugLogInfo("在线模式"); switch (PublicClass.app.app_type) { // case "medical": // //目录存在,说明已经成功下载 // if (Directory.Exists(targetSourcePath)) // { // DownLoad_complete(); // } // else // { // DownLoadSignGroup(PublicClass.app.ab_path, downloadFilePath); // } // break; default: // PublicClass.TimelineFilePath = targetSourcePath; PublicClass.app.xml_path = downloadFilePath; string tmpPath = this_app.ab_path + ""; PublicClass.app.ab_path = short_name + "_" + app_version + "." + suffix; //删除旧版本 int currentVersion = int.Parse(app_version); string lastVersionPath = path + short_name + "_"; for (int i = 0; i < currentVersion; i++) { if (Directory.Exists(lastVersionPath + i)) { Directory.Delete(lastVersionPath + i, true); } } if (!File.Exists(downloadFilePath) && !Directory.Exists(targetSourcePath)) { string[] files = Directory.GetFiles(path); for (int i = 0; i < files.Length; i++) { if (Vesal_DirFiles.get_file_name_from_full_path(files[i]).StartsWith(short_name)) { Vesal_DirFiles.DelFile(files[i]); } } //下载远程 DownLoadSignGroup(tmpPath, downloadFilePath); } else { DownLoad_complete(); } break; //} } }
IEnumerator update_db_process() { string fixdb = PublicClass.MedicalPath + "vesali.db"; string tmpdb = PublicClass.vesal_db_path + "temp.db"; Vesal_DirFiles.DelFile(tmpdb); if (File.Exists(fixdb)) { File.Move(fixdb, tmpdb); } show_progress.current_progress = 0.03f; string[] fname = Directory.GetFiles(PublicClass.MedicalPath); foreach (string file in fname) { string name = Vesal_DirFiles.get_file_name_from_full_path(file); string suffix = Vesal_DirFiles.get_name_suffix(name); if (suffix.ToLower() == "assetbundle") { Vesal_DirFiles.DelFile(PublicClass.filePath + name); Vesal_DirFiles.SaveAbfile(file, PublicClass.filePath + name, false); Vesal_DirFiles.DelFile(file); } } show_progress.current_progress = 0.1f; // string tmpdb = PublicClass.vesal_db_path + "temp.db"; //打开数据库进行更新 List <string> fix_tab_list = new List <string>(); if (File.Exists(tmpdb)) { fix_tab_list = PublicTools.get_table_list("temp.db"); if (fix_tab_list.Count != 0) { int tab_count = 0; foreach (string tab_name in fix_tab_list) { switch (tab_name) { case "GetSubModel": PublicTools.update_GetSubModel_db("temp.db"); break; case "GetStructList": PublicTools.update_GetStructList_db("temp.db"); break; case "GetStructAbList": PublicTools.update_GetStructAbList_db("temp.db"); break; case "LayserSubModel": PublicTools.update_LayserSubModel_db("temp.db"); break; case "ModelRelationModel": PublicTools.update_ModelRelationModel_db("temp.db"); break; case "RightMenuLayerModel": PublicTools.update_RightMenuLayerModel_db("temp.db"); break; case "RightMenuModel": PublicTools.update_RightMenuModel_db("temp.db"); break; case "SignNewInfo": PublicTools.update_SignNewInfo_db("temp.db"); break; case "GetTextureModelList": PublicTools.update_GetTextureModelList_db("temp.db"); break; case "noun_no_info": PublicTools.update_noun_no_info_db("temp.db"); break; case "AbInfo": PublicTools.update_ab_info_db("temp.db"); break; } tab_count++; show_progress.current_progress = 0.1f + 0.9f * tab_count / fix_tab_list.Count; yield return(null); } } else { PublicTools.update_GetSubModel_db("temp.db"); PublicTools.update_GetStructList_db("temp.db"); show_progress.current_progress = 0.35f; yield return(null); PublicTools.update_GetStructAbList_db("temp.db"); PublicTools.update_LayserSubModel_db("temp.db"); show_progress.current_progress = 0.5f; yield return(null); PublicTools.update_ModelRelationModel_db("temp.db"); PublicTools.update_RightMenuLayerModel_db("temp.db"); show_progress.current_progress = 0.7f; yield return(null); PublicTools.update_RightMenuModel_db("temp.db"); PublicTools.update_SignNewInfo_db("temp.db"); show_progress.current_progress = 0.85f; yield return(null); PublicTools.update_GetTextureModelList_db("temp.db"); PublicTools.update_noun_no_info_db("temp.db"); PublicTools.update_ab_info_db("temp.db"); show_progress.current_progress = 0.99f; yield return(null); } Vesal_DirFiles.DelFile(tmpdb); PublicTools.Model_AB_dic_update(); ManageModel.Instance.UpdateModelInfo(); } OperaStatus = AppOperState.Apprun; }
bool load_error_flag = false; //记录模型加载过程中的异常错误 IEnumerator LoadPrefabModel(string path, string name, Action count_load = null) { load_error_flag = false; //encrypt.DecryptFile(path, path.Remove(path.LastIndexOf('/')) + "/vesal.temp", "Vesal17788051918"); //解压ab文件 //yield return null; //防止卡死 yield return(new WaitForEndOfFrame()); string temp_path = PublicClass.tempPath + name + "temp.dat"; //vesal_log.vesal_write_log("load model phase 1 start: " + DateTime.Now.Ticks); //yield return null; AssetBundleCreateRequest assetBundleCreateRequest = null; try { if (load_list[load_count].type == "TEMP") { assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(path); } else { Vesal_DirFiles.GetAbfile2(path, temp_path); assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(temp_path); } //assetBundleCreateRequest = AssetBundle.LoadFromMemoryAsync(Vesal_DirFiles.GetAbfile(path, temp_path)); } catch (Exception ex) { load_error_flag = true; UnityEngine.Debug.Log(ex.Message); UnityEngine.Debug.Log(ex.StackTrace); vesal_log.vesal_write_log("assetbundle load error in :" + name); vesal_log.vesal_write_log("error message:" + ex.Message); if (File.Exists(temp_path)) { try { Vesal_DirFiles.DelFile(temp_path); } catch { } } } //Vesal_DirFiles.DelFile(temp_path); if (assetBundleCreateRequest != null && load_error_flag == false) { yield return(assetBundleCreateRequest); //vesal_log.vesal_write_log("load model phase 3 start: " + DateTime.Now.Ticks); //AssetBundle curBundleObj = AssetBundle.LoadFromMemory(Vesal_DirFiles.GetAbfile(path, temp_path)); GameObject CurrentObj = null; GameObject realObj = null; AssetBundleRequest abr = null; try { if (load_list[load_count].type == "TEMP") { abr = assetBundleCreateRequest.assetBundle.LoadAssetAsync(Vesal_DirFiles.get_file_name_from_full_path(name), typeof(GameObject)); } else { abr = assetBundleCreateRequest.assetBundle.LoadAssetAsync(name, typeof(GameObject)); //vesal_log.vesal_write_log("load model phase 4 start: " + DateTime.Now.Ticks); } } catch (Exception ex) { load_error_flag = true; UnityEngine.Debug.Log(ex.Message); UnityEngine.Debug.Log(ex.StackTrace); vesal_log.vesal_write_log("assetbundle load error in :" + name); vesal_log.vesal_write_log("error message:" + ex.Message); } yield return(abr); if (abr != null && abr.asset != null) { CurrentObj = (GameObject)abr.asset; realObj = Instantiate(CurrentObj); } else { load_error_flag = true; vesal_log.vesal_write_log("assetbundle load error in :" + name); } if (CurrentObj != null && realObj != null & load_error_flag == false) { yield return(realObj); //vesal_log.vesal_write_log("load model phase 5 start: " + DateTime.Now.Ticks); realObj.name = realObj.name.Replace("(Clone)", ""); Transform Transform_parent; print("name :" + load_list[load_count].name + " type: " + load_list[load_count].type); if (load_list[load_count].type == "TEMP") { print("---------- temp model 管理器"); Transform_parent = PublicClass.Transform_temp; } else { ReadModel(realObj); Transform_parent = PublicClass.Transform_parent; load_list[load_count].source = CurrentObj; load_list[load_count].instance = realObj; } realObj.transform.SetParent(Transform_parent); assetBundleCreateRequest.assetBundle.Unload(false); Transform_parent.gameObject.SetActive(false); if ((load_list[load_count].type != "TEMP") && (File.Exists(temp_path))) { try { Vesal_DirFiles.DelFile(temp_path); } catch { } } //vesal_log.vesal_write_log("load model phase 5 end: " + DateTime.Now.Ticks); } } if (count_load != null) { count_load(); } }
static void update_db_process(string fixdb, Action count_load) { string tmpdb = PublicClass.vesal_db_path + "temp.db"; Vesal_DirFiles.DelFile(tmpdb); if (File.Exists(fixdb)) { File.Copy(fixdb, tmpdb); } string[] fname = Directory.GetFiles(PublicClass.MedicalPath); //打开数据库进行更新 List <string> fix_tab_list = new List <string>(); if (File.Exists(tmpdb)) { fix_tab_list = PublicTools.get_table_list("temp.db"); if (fix_tab_list.Count != 0) { int tab_count = 0; foreach (string tab_name in fix_tab_list) { switch (tab_name) { case "GetSubModel": PublicTools.update_GetSubModel_db("temp.db"); break; case "GetStructList": PublicTools.update_GetStructList_db("temp.db"); break; case "GetStructAbList": PublicTools.update_GetStructAbList_db("temp.db"); break; case "LayserSubModel": PublicTools.update_LayserSubModel_db("temp.db"); break; case "ModelRelationModel": PublicTools.update_ModelRelationModel_db("temp.db"); break; case "RightMenuLayerModel": PublicTools.update_RightMenuLayerModel_db("temp.db"); break; case "RightMenuModel": PublicTools.update_RightMenuModel_db("temp.db"); break; case "SignNewInfo": PublicTools.update_SignNewInfo_db("temp.db"); break; case "GetTextureModelList": PublicTools.update_GetTextureModelList_db("temp.db"); break; case "noun_no_info": PublicTools.update_noun_no_info_db("temp.db"); break; case "AbInfo": PublicTools.update_ab_info_db("temp.db"); break; } tab_count++; } } else { PublicTools.update_GetSubModel_db("temp.db"); PublicTools.update_GetStructList_db("temp.db"); PublicTools.update_GetStructAbList_db("temp.db"); PublicTools.update_LayserSubModel_db("temp.db"); PublicTools.update_ModelRelationModel_db("temp.db"); PublicTools.update_RightMenuLayerModel_db("temp.db"); PublicTools.update_RightMenuModel_db("temp.db"); PublicTools.update_SignNewInfo_db("temp.db"); PublicTools.update_GetTextureModelList_db("temp.db"); PublicTools.update_noun_no_info_db("temp.db"); PublicTools.update_ab_info_db("temp.db"); } Vesal_DirFiles.DelFile(tmpdb); } if (count_load != null) { count_load(); } }
//public static bool stepLoad = false; IEnumerator LoadPrefabModel(string path, string name, Action count_load = null) { Debug.Log(name); //encrypt.DecryptFile(path, path.Remove(path.LastIndexOf('/')) + "/vesal.temp", "Vesal17788051918"); //解压ab文件 //yield return null; //防止卡死 load_error_flag = false; //while (!stepLoad) { // yield return null; //} yield return(new WaitForEndOfFrame()); string temp_path = PublicClass.tempPath + name + "temp.dat"; vesal_log.vesal_write_log(name); //vesal_log.vesal_write_log("load model phase 1 start: " + DateTime.Now.Ticks); //yield return null; AssetBundleCreateRequest assetBundleCreateRequest = null; try { Vesal_DirFiles.GetAbfile2(path, temp_path); //if (File.Exists(temp_path)) // Debug.Log(temp_path + "exsit!!!!!!!!!!!!!"); assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(temp_path); //assetBundleCreateRequest = AssetBundle.LoadFromMemoryAsync(Vesal_DirFiles.GetAbfile(path, temp_path)); } catch (Exception ex) { load_error_flag = true; vesal_log.vesal_write_log("assetbundle load error in :" + name); vesal_log.vesal_write_log("error message:" + ex.Message); } //Vesal_DirFiles.DelFile(temp_path); if (assetBundleCreateRequest != null && load_error_flag == false) { yield return(assetBundleCreateRequest); GameObject CurrentObj = null; GameObject realObj = null; AssetBundleRequest abr = null; try { // abr = assetBundleCreateRequest.assetBundle.LoadAssetAsync(name, typeof(GameObject)); CurrentObj = (GameObject)assetBundleCreateRequest.assetBundle.LoadAsset(name, typeof(GameObject));; realObj = Instantiate(CurrentObj); #if UNITY_EDITOR MeshFilter[] filters = null; filters = realObj.GetComponentsInChildren <MeshFilter>(true); int topCount = 0; int triCount = 0; int meshCount = 0; if (filters != null) { for (int j = 0; j < filters.Length; j++) { MeshFilter f = filters[j]; topCount += f.sharedMesh.vertexCount; triCount += f.sharedMesh.triangles.Length / 3; meshCount++; } } LoadResult += string.Format("{0,20}\t{1,20}\t{2,20}", name, topCount, topCount / 8881.123208f) + "\n"; //Debug.LogError(name + "总共Mesh=" + meshCount + " 总共顶点=" + topCount + " 总共三角形=" + triCount); //Debug.LogError(string.Format("{0,20}\t{1,20}\t{2,20}M", name, topCount, topCount / 8881.123208f)); // Debug.LogError(name + " 总共顶点=" + topCount +" 占用内存:" + topCount / 8881.123208f + "M"); #endif } catch (Exception ex) { load_error_flag = true; vesal_log.vesal_write_log("assetbundle load error in :" + name); vesal_log.vesal_write_log("error message:" + ex.Message); } //yield return abr; //if (abr != null && abr.asset != null) //{ // CurrentObj = (GameObject)abr.asset; // realObj = Instantiate(CurrentObj); //} //else //{ // load_error_flag = true; // vesal_log.vesal_write_log("assetbundle load error in :" + name); //} if (CurrentObj != null && realObj != null && load_error_flag == false) { yield return(realObj); realObj.name = realObj.name.Replace("(Clone)", ""); realObj.transform.SetParent(PublicClass.Transform_parent); assetBundleCreateRequest.assetBundle.Unload(false); load_list[count].source = CurrentObj; load_list[count].instance = realObj; if (File.Exists(temp_path)) { try { Vesal_DirFiles.DelFile(temp_path); } catch { } } } } if (count_load != null) { count_load(); } }
/// <summary> /// 加载标注 /// </summary> /// <param name="downLoad_name">标注ab</param> public void Load_ps(string downLoad_name, string ab_path) { #if UNITY_EDITOR || UNITY_STANDALONE_WIN var local_db = new DbRepository <Abfiles>(); string temp_path = PublicClass.tempPath + "temp.dat"; local_db.DataService("vesali.db"); Abfiles res = local_db.SelectOne <Abfiles>((temp) => { if (temp.file_name == Vesal_DirFiles.get_file_name_from_full_path(ab_path)) { return(true); } else { return(false); } }); local_db.Close(); if (res == null || !File.Exists(ab_path)) { if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.plugin) { try { curBundleObj = LoadPSModel(LoadModel_ppt.url, LoadModel_ppt.password, LoadModel_ppt.sceneName); } catch (Exception e) { Debug.Log(e.Message); } } } else { //解压ab文件 psmodel = null; ReadTextureAB(PublicClass.filePath + "sign/"); Vesal_DirFiles.GetAbfile_Synchronize(ab_path, temp_path); curBundleObj = AssetBundle.LoadFromFile(temp_path); } GameObject realObj = (GameObject)curBundleObj.LoadAsset(downLoad_name, typeof(GameObject)); CurrentObj = Instantiate(realObj); CurrentObj.name = "temp_parent"; CurrentObj.name = CurrentObj.name.Replace("(Clone)", ""); // realObj.transform.SetParent(Transform_parent); // Camera.main.GetComponent<ChooseModel>().SetCameraPosition(CurrentObj.transform); Reset(); GetMaterialsFromModel(downLoad_name); curBundleObj.Unload(false);//卸载内存中的资源 if (File.Exists(temp_path)) { Vesal_DirFiles.DelFile(temp_path); } #elif UNITY_ANDROID || UNITY_IOS downLoad_name = GetSAFromSignidTable(PublicClass.app.struct_name); curBundleObj = AssetBundle.LoadFromFile(PublicClass.filePath + "Android_sign/" + downLoad_name + ".assetbundle"); GameObject realObj = (GameObject)curBundleObj.LoadAsset(downLoad_name, typeof(GameObject)); CurrentObj = Instantiate(realObj); CurrentObj.name = "temp_parent"; CurrentObj.name = CurrentObj.name.Replace("(Clone)", ""); Reset(); GetMaterialsFromModel(downLoad_name); curBundleObj.Unload(false); //卸载内存中的资源 #endif }
IEnumerator update_process(int index, Action count_load = null) { string fix_file = PublicClass.filePath + Vesal_DirFiles.get_file_name_from_full_path(update_list[index].name); if (Directory.Exists(PublicClass.UpdatePath)) { Vesal_DirFiles.CreateDir(PublicClass.UpdatePath); } try { Vesal_DirFiles.UnZip(fix_file, PublicClass.UpdatePath, true); Vesal_DirFiles.DelFile(fix_file); } catch (System.Exception e) { Debug.Log(e.Message); Debug.Log(e.StackTrace); } yield return(null); //打开数据库进行更新 string[] files = Directory.GetFiles(PublicClass.UpdatePath); List <string> fix_tab_list = new List <string>(); foreach (string tagetfile in files) { string target = Vesal_DirFiles.get_file_name_from_full_path(tagetfile); if (target == "vesali.db") { File.Copy(tagetfile, PublicClass.vesal_db_path + "temp.db", true); fix_tab_list = PublicTools.get_table_list("temp.db"); int tab_count = 0; if (fix_tab_list.Count != 0) { foreach (string tab_name in fix_tab_list) { switch (tab_name) { case "GetSubModel": PublicTools.update_GetSubModel_db("temp.db"); break; case "GetStructList": PublicTools.update_GetStructList_db("temp.db"); break; case "GetStructAbList": PublicTools.update_GetStructAbList_db("temp.db"); break; case "LayserSubModel": PublicTools.update_LayserSubModel_db("temp.db"); break; case "ModelRelationModel": PublicTools.update_ModelRelationModel_db("temp.db"); break; case "RightMenuLayerModel": PublicTools.update_RightMenuLayerModel_db("temp.db"); break; case "RightMenuModel": PublicTools.update_RightMenuModel_db("temp.db"); break; case "SignNewInfo": PublicTools.update_SignNewInfo_db("temp.db"); break; case "GetTextureModelList": PublicTools.update_GetTextureModelList_db("temp.db"); break; case "noun_no_info": PublicTools.update_noun_no_info_db("temp.db"); break; case "AbInfo": PublicTools.update_ab_info_db("temp.db"); break; } tab_count++; showProgress.current_progress = (float)index / update_list.Count + (float)tab_count / fix_tab_list.Count / update_list.Count; yield return(null); } } else { PublicTools.update_GetSubModel_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.1f / update_list.Count; PublicTools.update_GetStructList_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.3f / update_list.Count; yield return(null); PublicTools.update_GetStructAbList_db("temp.db"); PublicTools.update_LayserSubModel_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.5f / update_list.Count; yield return(null); PublicTools.update_ModelRelationModel_db("temp.db"); PublicTools.update_RightMenuLayerModel_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.65f / update_list.Count; yield return(null); PublicTools.update_RightMenuModel_db("temp.db"); PublicTools.update_SignNewInfo_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.8f / update_list.Count; yield return(null); PublicTools.update_GetTextureModelList_db("temp.db"); PublicTools.update_noun_no_info_db("temp.db"); PublicTools.update_ab_info_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.99f / update_list.Count; yield return(null); } } //拷贝文件 } string[] dirs = Directory.GetDirectories(PublicClass.UpdatePath); foreach (string targetdir in dirs) { string subdir = Vesal_DirFiles.get_file_name_from_full_path(targetdir); if (subdir.ToUpper() == "ANDROID_SIGN") { Vesal_DirFiles.Vesal_DirCopy(targetdir, PublicClass.SignPath); } if (subdir.ToUpper() == "MODEL") { Vesal_DirFiles.Vesal_DirCopy(targetdir, PublicClass.ModelPath); } } yield return(null); //删除update数据 try { Directory.Delete(PublicClass.UpdatePath, true); Vesal_DirFiles.DelFile(PublicClass.vesal_db_path + "temp.db"); } catch (System.Exception e) { Debug.Log(e.Message); Debug.Log(e.StackTrace); } yield return(null); if (count_load != null) { count_load(); } }
public static void InitStaticData() { if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer || PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.pc) { int_load_AB_nums = 100; } else { int_load_AB_nums = 0; } int mem = SystemInfo.systemMemorySize; #if UNITY_EDITOR //QualitySettings.currentLevel = QualityLevel.Fastest; //Quality = Run_Quality.POOL; QualitySettings.currentLevel = QualityLevel.Good; Quality = Run_Quality.GOOD; #elif UNITY_STANDALONE_WIN if (mem <= 4400) { QualitySettings.currentLevel = QualityLevel.Fastest; Quality = Run_Quality.POOL; } else { QualitySettings.currentLevel = QualityLevel.Good; Quality = Run_Quality.GOOD; } #elif UNITY_IOS if (mem <= 1100) { QualitySettings.currentLevel = QualityLevel.Fastest; Quality = Run_Quality.POOL; } else { QualitySettings.currentLevel = QualityLevel.Good; Quality = Run_Quality.GOOD; } #elif UNITY_ANDROID if (mem <= 3300) { QualitySettings.currentLevel = QualityLevel.Fastest; Quality = Run_Quality.POOL; } else { QualitySettings.currentLevel = QualityLevel.Good; Quality = Run_Quality.GOOD; } #else #endif Debug.Log("Quality :" + Quality); cameraBackAxisPosition = Vector3.zero; cameraBackAxisRotation = Vector3.zero; currentState = RunState.Loading; currentModle = ModleChoose.MainModel; Difficult_Index = 0; data_list_count = 0; tableCount = 15; // app_json_str = ""; filePath = Application.persistentDataPath + "/"; #if UNITY_EDITOR if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer || PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.WeiKePlayer) { platform = asset_platform.pc; fileLocalStreamingPath = "file://" + Application.streamingAssetsPath + "/"; filePath = Application.streamingAssetsPath + "/"; } else if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.demo_pc || PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.pc) { platform = asset_platform.pc; fileLocalStreamingPath = Application.streamingAssetsPath + "/"; filePath = Application.persistentDataPath.Substring(0, Application.persistentDataPath.LastIndexOf("AppData") + 7) + "/roaming/Vesal_unity_PC/"; } else if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.plugin) { platform = asset_platform.pc; fileLocalStreamingPath = "file://" + Application.streamingAssetsPath + "/"; filePath = Application.persistentDataPath.Substring(0, Application.persistentDataPath.LastIndexOf("AppData") + 7) + "/roaming/Vesal/"; } else { platform = asset_platform.android; fileLocalStreamingPath = "file://" + Application.streamingAssetsPath + "/"; } #elif UNITY_IOS platform = asset_platform.ios; fileLocalStreamingPath = "file://" + Application.dataPath + "/Raw/"; #elif UNITY_ANDROID platform = asset_platform.android; fileLocalStreamingPath = "jar:file://" + Application.dataPath + "!/assets/"; #elif UNITY_STANDALONE_WIN platform = asset_platform.pc; fileLocalStreamingPath = Application.streamingAssetsPath + "/"; //filePath = Application.persistentDataPath.Substring(0, Application.persistentDataPath.LastIndexOf("AppData") + 7) + "/roaming/Vesal_unity_PC/"; if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer || PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.WeiKePlayer) { filePath = Vesal_DirFiles.get_dir_from_full_path(Application.dataPath) + "PptPlayer_Data/StreamingAssets/"; } else { filePath = Application.persistentDataPath.Substring(0, Application.persistentDataPath.LastIndexOf("AppData") + 7) + "/roaming/Vesal_unity_PC/"; } Debug.Log("UNITY_STANDALONE_WIN filePath:" + filePath); #endif tempPath = filePath + "temp/"; Vesal_DirFiles.DelFile(tempPath + "temp.dat"); vesal_db_path = filePath + "db/"; sign_texture_path = filePath + "sign_texture/"; UpdatePath = filePath + "Update/"; SignPath = filePath + "Android_sign/"; ModelPath = filePath + "model/"; MedicalPath = filePath + "Mediacl/"; xluaPath = filePath + "Lua-HotFix/"; TimelineFilePath = filePath + "Anim_Timeline/"; WeiKePlayer_path = filePath + "microlesson/"; Video_path = filePath + "acu_vdo/"; Anim_TimelinePath = filePath + "Anim_Timeline/"; BookMarkPath = filePath + "BookmarkFile/"; if (Quality == Run_Quality.GOOD) { MAX_Ab_num = 15; } else { MAX_Ab_num = 10; } #if UNITY_DEBUG // get_server_interface = "http://api.vesal.cn:8000/vesal-jiepao-prod/server?type=0"; get_server_interface = "http://118.24.119.234:8083/vesal-jiepao-test/server?type=0"; #else //get_server_interface = "http://api.vesal.cn:8000/vesal-jiepao-prod/server?type=0";//正式服 get_server_interface = "http://114.115.210.145:8083/vesal-jiepao-test/server?type=0";//测试服 #endif fix_server_interface = "v1/app/member/getCode"; //server_ip = vesal_network.Vesal_Network.get_ipfromlist(get_server_interface); //server_test_url = server_ip + fix_server_interface; online_mode = true; is_enter_server_control = false; // isLanScaple = true; // isLanScaple = true; DataManagerStatus = DataIntState.Null; is_has_app_buff = false; isRotateScreen = false; DebugLog.DebugLogInfo("---------------设备内存-------------------" + mem); }
IEnumerator LoadPrefabModel(string path, string name, Action count_load = null) { load_error_flag = false; //防止卡死 yield return(new WaitForEndOfFrame()); DebugLog.DebugLogInfo("00FF00", "assetbundle loading ---" + path + name); string temp_path = PublicClass.tempPath + name + "temp.dat"; AssetBundleCreateRequest assetBundleCreateRequest = null; try { Vesal_DirFiles.GetAbfile2(path, temp_path); assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(temp_path); //assetBundleCreateRequest = AssetBundle.LoadFromMemoryAsync(Vesal_DirFiles.GetAbfile(path, temp_path)); } catch (Exception ex) { load_error_flag = true; vesal_log.vesal_write_log("assetbundle load error in :" + name); vesal_log.vesal_write_log("error message:" + ex.Message); } if (assetBundleCreateRequest != null && load_error_flag == false) { yield return(assetBundleCreateRequest); GameObject CurrentObj = null; GameObject realObj = null; AssetBundleRequest abr = null; try { abr = assetBundleCreateRequest.assetBundle.LoadAssetAsync(name, typeof(GameObject)); } catch (Exception ex) { load_error_flag = true; vesal_log.vesal_write_log("assetbundle load error in :" + name); vesal_log.vesal_write_log("error message:" + ex.Message); } yield return(abr); if (abr != null && abr.asset != null) { CurrentObj = (GameObject)abr.asset; realObj = Instantiate(CurrentObj); } else { load_error_flag = true; vesal_log.vesal_write_log("assetbundle load error in :" + name); } if (CurrentObj != null && realObj != null & load_error_flag == false) { realObj.name = realObj.name.Replace("(Clone)", ""); ReadModel(realObj); Transform Transform_parent = PublicClass.Transform_parent; realObj.transform.SetParent(Transform_parent); assetBundleCreateRequest.assetBundle.Unload(false); //Transform_parent.gameObject.SetActive(false); load_list[load_count].source = CurrentObj; load_list[load_count].instance = realObj; if (File.Exists(temp_path)) { try { Vesal_DirFiles.DelFile(temp_path); } catch { } } } } if (count_load != null) { count_load(); } }
public static void InitStaticData() { int mem = SystemInfo.systemMemorySize; #if UNITY_EDITOR //QualitySettings.currentLevel = QualityLevel.Fastest; //Quality = Run_Quality.POOL; QualitySettings.currentLevel = QualityLevel.Good; Quality = Run_Quality.GOOD; #elif UNITY_STANDALONE_WIN if (mem <= 4400) { QualitySettings.currentLevel = QualityLevel.Fastest; Quality = Run_Quality.POOL; } else { QualitySettings.currentLevel = QualityLevel.Good; Quality = Run_Quality.GOOD; } #elif UNITY_IOS if (mem <= 1100) { QualitySettings.currentLevel = QualityLevel.Fastest; Quality = Run_Quality.POOL; } else { QualitySettings.currentLevel = QualityLevel.Good; Quality = Run_Quality.GOOD; } #elif UNITY_ANDROID if (mem <= 3300) { QualitySettings.currentLevel = QualityLevel.Fastest; Quality = Run_Quality.POOL; } else { QualitySettings.currentLevel = QualityLevel.Good; Quality = Run_Quality.GOOD; } #else #endif Debug.Log("Quality :" + Quality); cameraBackAxisPosition = Vector3.zero; cameraBackAxisRotation = Vector3.zero; currentState = RunState.Loading; currentModle = ModleChoose.MainModel; Difficult_Index = 0; data_list_count = 0; tableCount = 15; filePath = Application.persistentDataPath + "/"; #if UNITY_EDITOR fileLocalStreamingPath = "file://" + Application.streamingAssetsPath + "/"; filePath = Application.streamingAssetsPath + "/"; #elif UNITY_IOS fileLocalStreamingPath = "file://" + Application.dataPath + "/Raw/"; #elif UNITY_ANDROID fileLocalStreamingPath = "jar:file://" + Application.dataPath + "!/assets/"; #elif UNITY_STANDALONE_WIN fileLocalStreamingPath = Application.streamingAssetsPath + "/"; filePath = Application.persistentDataPath.Substring(0, Application.persistentDataPath.LastIndexOf("AppData") + 7) + "/roaming/Vesal_unity_PC/"; Debug.Log("UNITY_STANDALONE_WIN filePath:" + filePath); #endif tempPath = filePath + "temp/"; Vesal_DirFiles.DelFile(tempPath + "temp.dat"); vesal_db_path = filePath + "db/"; sign_texture_path = filePath + "sign_texture/"; UpdatePath = filePath + "Update/"; SignPath = filePath + "Android_sign/"; ModelPath = filePath + "model/"; MedicalPath = filePath + "Mediacl/"; xluaPath = filePath + "Lua-HotFix/"; TimelineFilePath = filePath + "Anim_Timeline/"; WeiKePlayer_path = filePath + "microlesson/"; Video_path = filePath + "acu_vdo/"; Anim_TimelinePath = filePath + "Anim_Timeline/"; BookMarkPath = filePath + "BookmarkFile/"; if (Quality == Run_Quality.GOOD) { MAX_Ab_num = 15; } else { MAX_Ab_num = 10; } //get_server_interface = "http://api.vesal.cn:8000/vesal-jiepao-prod/server?type=0";//正式服 get_server_interface = "http://114.115.210.145:8083/vesal-jiepao-test/server?type=0";//测试服 fix_server_interface = "v1/app/member/getCode"; online_mode = true; is_enter_server_control = false; is_has_app_buff = false; isRotateScreen = false; DebugLog.DebugLogInfo("---------------设备内存-------------------" + mem); }