private void ShowExportTools() { GUILayout.Label("文件导出工具"); if (GUILayout.Button("将文件导出到本地服务器", GUILayout.Width(200))) { string localBundleResourcesFolder = PathConfig.GetLocalBundleResourcesFolderByVersion(resVersion); if (Directory.Exists(localBundleResourcesFolder)) { Directory.Delete(localBundleResourcesFolder, true); } DirectoryEx.DirectoryCopy(PathConfig.GetExportPathByVersion(resVersion), localBundleResourcesFolder, true); string[] versionResFolderList = Directory.GetDirectories(PathConfig.localUpdateBundleUrl); XDocument xDoc = new XDocument(); XElement root = new XElement("Root"); xDoc.Add(root); foreach (string path in versionResFolderList) { string versionFolder = Path.GetFileName(path.Replace("\\", "/")); root.Add(new XElement("version", versionFolder)); } xDoc.SafeSaveWithoutDeclaration(PathConfig.localVersionInfoUrl); } }
private static void CopyOldTools(string outerToolsFolderPath, ILongWaitBroker broker) { //Copy tools to a different folder then Directory.Move if successful. string tempOuterToolsFolderPath = string.Concat(outerToolsFolderPath, @"_installing"); if (Directory.Exists(tempOuterToolsFolderPath)) { DirectoryEx.SafeDelete(tempOuterToolsFolderPath); // Not sure this is necessay, but just to be safe if (Directory.Exists(tempOuterToolsFolderPath)) { throw new Exception(Resources.Program_CopyOldTools_Error_copying_external_tools_from_previous_installation); } } // Must create the tools directory to avoid ending up here again next time Directory.CreateDirectory(tempOuterToolsFolderPath); ToolList toolList = Settings.Default.ToolList; int numTools = toolList.Count; const int endValue = 100; int progressValue = 0; // ReSharper disable once UselessBinaryOperation (in case we decide to start at progress>0 for display purposes) int increment = (endValue - progressValue) / (numTools + 1); foreach (var tool in toolList) { string toolDirPath = tool.ToolDirPath; if (!string.IsNullOrEmpty(toolDirPath) && Directory.Exists(toolDirPath)) { string foldername = Path.GetFileName(toolDirPath); string newDir = Path.Combine(outerToolsFolderPath, foldername); string tempNewDir = Path.Combine(tempOuterToolsFolderPath, foldername); if (!Directory.Exists(tempNewDir)) { DirectoryEx.DirectoryCopy(toolDirPath, tempNewDir, true); } tool.ToolDirPath = newDir; // Update the tool to point to its new directory. tool.ArgsCollectorDllPath = tool.ArgsCollectorDllPath.Replace(toolDirPath, newDir); } if (broker.IsCanceled) { // Don't leave around a corrupted directory DirectoryEx.SafeDelete(tempOuterToolsFolderPath); return; } progressValue += increment; broker.ProgressValue = progressValue; } Directory.Move(tempOuterToolsFolderPath, outerToolsFolderPath); Settings.Default.ToolList = ToolList.CopyTools(toolList); }
//安装sdk public void SetupSDK(SDKType sdkType) { string backupPath = ModuleConst.GetSDKBackupPath(sdkType); string setupPath = ModuleConst.GetSDKPath(sdkType); string pluginPathBeforeSetup = Path.Combine(setupPath, PathConfig.PluginsFolderName); if (Directory.Exists(setupPath)) { Debug.logger.LogError("SDK Setup Error", "You has setup the " + sdkType.ToString() + " SDK"); return; } PathEx.MakeDirectoryExist(setupPath); DirectoryEx.DirectoryCopy(backupPath, setupPath, true); //安装Plugin if (Directory.Exists(pluginPathBeforeSetup)) { Directory.Move(pluginPathBeforeSetup, PathConfig.pluginPath); } }
//将核心数据拷贝至Resources下 private static void CheckCoreData() { string localCoreDataPath = PathConfig.GetLocalGameDataPath(PathConfig.DataType.Core); PathEx.MakeDirectoryExist(PathConfig.localCoreDataBackupPath); PathEx.MakeDirectoryExist(localCoreDataPath); if (!Directory.Exists(localCoreDataPath) && Directory.GetFiles(PathConfig.localCoreDataBackupPath).Length > 0) { if (Directory.Exists(PathConfig.localCoreDataBackupPath)) { PathEx.MakeDirectoryExist(localCoreDataPath); DirectoryEx.DirectoryCopy(PathConfig.localCoreDataBackupPath, localCoreDataPath, true); } else { Debug.logger.LogError("Core Data Error", "You Lost Your Core Data"); } } }
//添加模块 public static bool AddModule(MODULE_SYMBOL symbol) { string tempPath = ModuleConst.GetSymbolTempPath(symbol); string modulePath = ModuleConst.GetSymbolPath(symbol); //检查目录如果不存在则拷贝 if (!Directory.Exists(modulePath)) { if (Directory.Exists(tempPath)) { PathEx.MakeDirectoryExist(modulePath); DirectoryEx.DirectoryCopy(tempPath, modulePath, true); } else { Debug.logger.Log("can't find the module path" + modulePath); return(false); } } AddSymbol(symbol); return(true); }
//刷新备份文件夹 public static void RefreshBackUp() { ModuleControl.CheckAllSymbol(); Array symbolArr = Enum.GetValues(typeof(MODULE_SYMBOL)); foreach (MODULE_SYMBOL symbol in symbolArr) { string modulePath = ModuleConst.GetSymbolPath(symbol); string moduleTempPath = ModuleConst.GetSymbolTempPath(symbol); if (!Directory.Exists(modulePath)) { return; } if (Directory.Exists(moduleTempPath)) { Directory.Delete(moduleTempPath, true); Directory.CreateDirectory(moduleTempPath); } DirectoryEx.DirectoryCopy(modulePath, moduleTempPath, true); } ModuleControl.CheckAllSymbol(); }
public static void CheckAllSymbol() { Array symbolArr = Enum.GetValues(typeof(MODULE_SYMBOL)); List <MODULE_SYMBOL> symbols = GetSymbolInfo(); bool needRestart = false; for (int i = 0; i < symbolArr.Length; i++) { MODULE_SYMBOL symbol = (MODULE_SYMBOL)symbolArr.GetValue(i); string tempPath = ModuleConst.GetSymbolTempPath(symbol); string modulePath = ModuleConst.GetSymbolPath(symbol); EditorUtility.DisplayProgressBar("Check Modules", "Checking Modules " + symbol.ToString() + " " + (i + 1) + "/" + symbolArr.Length, (float)i + 1 / (float)symbolArr.Length); //检查模块备份 if (!Directory.Exists(tempPath)) { if (!Directory.Exists(modulePath)) { Debug.logger.LogError("ResetCoreError", "Lose the module " + symbol.ToString()); } else { PathEx.MakeDirectoryExist(tempPath); DirectoryEx.DirectoryCopy(modulePath, tempPath, true); EditorUtility.DisplayProgressBar("Check Modules", "Copy Module " + symbol.ToString() + "to backup " + (i + 1) + "/" + symbolArr.Length, (float)(i + 1) / (float)symbolArr.Length); } } //存在宏定义 但是不存在实际模块 if (symbols.Contains(symbol) && (!Directory.Exists(modulePath) || Directory.GetFiles(modulePath).Length == 0)) { AddModule(symbol); EditorUtility.DisplayProgressBar("Check Modules", "Add Module " + symbol.ToString() + "to ResetCore " + (i + 1) + "/" + symbolArr.Length, (float)(i + 1) / (float)symbolArr.Length); needRestart = true; } //不存在宏定义 但是存在实际模块 添加模块 if (!symbols.Contains(symbol) && Directory.Exists(modulePath) && Directory.GetFiles(modulePath).Length != 0) { if (ModuleConst.defaultSymbol.Contains(symbol)) { AddModule(symbol); EditorUtility.DisplayProgressBar("Check Modules", "Add Module " + symbol.ToString() + "to ResetCore " + (i + 1) + "/" + symbolArr.Length, (float)(i + 1) / (float)symbolArr.Length); needRestart = true; } else { RemoveModule(symbol); EditorUtility.DisplayProgressBar("Check Modules", "Remove Module " + symbol.ToString() + "from ResetCore " + (i + 1) + "/" + symbolArr.Length, (float)(i + 1) / (float)symbolArr.Length); needRestart = true; } } } AssetDatabase.Refresh(); EditorUtility.ClearProgressBar(); if (needRestart) { EditorUtility.DisplayDialog("Need Restart Project", "You may need to Restart the project to apply your setting", "Ok"); } }