/// <summary> /// 结束解压,开始加载器预处理 /// </summary> /// <returns></returns> IEnumerator endUnzip() { initProgress("正在加载幻灯片"); yield return(null); if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer || PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.WeiKePlayer) { DirectoryInfo di = new DirectoryInfo(PPTHomePageController.TempFilePath); PPTGlobal.PPTPath = di.GetDirectories()[0].FullName; string id = System.Guid.NewGuid().ToString("N"); string renamePath = Vesal_DirFiles.get_dir_from_full_path(PPTGlobal.PPTPath) + id; //重命名文件夹,替换中文 Directory.Move(PPTGlobal.PPTPath, renamePath); PPTGlobal.PPTPath = renamePath; PPTGlobal.PPTPath = PPTGlobal.PPTPath.Replace("\\", "/"); if (!PPTGlobal.PPTPath.EndsWith("/")) { PPTGlobal.PPTPath += "/"; } } else { int pos = PublicClass.app.xml_path.LastIndexOf("."); string basePath = ""; if (pos >= 0) { basePath = PublicClass.app.xml_path.Substring(0, pos); } basePath = basePath + "/"; message = Vesal_DirFiles.GetFirstDirInDir(basePath); Debug.Log("basePath:" + basePath); //Vesal_DirFiles.ExtractAppData(ref basePath, ref message); string renamePath = basePath + PublicClass.app.app_id; if (basePath + message != renamePath) { //if (Directory.Exists(renamePath)) { // Directory.Delete(renamePath,true); //} Directory.Move(basePath + message, renamePath); message = PublicClass.app.app_id; } PPTGlobal.PPTPath = basePath + message + "/"; Debug.Log(PPTGlobal.PPTPath); } yield return(null); //progressPanel.SetActive(false); PPTGlobal.pptStatus = PPTGlobal.PPTStatus.initial; }
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(); } }
/// <summary> /// 打开微课播放器 /// </summary> /// <param name="exportPath">导出路径</param> /// <param name="fileName">播放文件名</param> public void OpenWeiKePlayer(string exportPath, string fileName) { //"WeiKePlayer_Data/StreamingAssets/" if (File.Exists(exportPath + fileName + ".vsl")) { foreach (System.Diagnostics.Process pro in System.Diagnostics.Process.GetProcessesByName("WeiKePlayer")) { pro.Kill(); } //exportPath + DirectName+".vsl" String path = Vesal_DirFiles.get_dir_from_full_path(Application.dataPath) + "WeiKePlayer_Data/StreamingAssets/WeiKePlayer/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } BackUpVsl(path); try { File.Copy(exportPath + fileName + ".vsl", path + fileName + ".vsl"); } catch (Exception e) { Debug.Log(e.Message); } string exePath = Vesal_DirFiles.get_dir_from_full_path(Application.dataPath) + "WeiKePlayer.exe"; Debug.Log(exePath); if (File.Exists(exePath)) { System.Diagnostics.ProcessStartInfo ps = new System.Diagnostics.ProcessStartInfo(exePath); ps.Arguments = exportPath + fileName + ".vsl"; System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo = ps; p.Start(); p.WaitForInputIdle(); } } }
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; //} } }
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); }