//移除模块
        public static bool RemoveModule(MODULE_SYMBOL symbol)
        {
            string tempPath   = ModuleConst.GetSymbolTempPath(symbol);
            string modulePath = ModuleConst.GetSymbolPath(symbol);

            //如果找不到备份文件夹则复制到备份文件夹,如果备份文件夹中有了,则直接删除
            if (!Directory.Exists(tempPath))
            {
                PathEx.MakeDirectoryExist(tempPath);
                Debug.logger.Log("can't find the temp directory, will move the module to the temp directory");
                if (Directory.Exists(modulePath))
                {
                    Directory.Move(modulePath, tempPath);
                    Directory.Delete(modulePath, true);
                }
            }
            else
            {
                if (Directory.Exists(modulePath))
                {
                    Directory.Delete(modulePath, true);
                }
            }
            RemoveSymbol(symbol);

            return(true);
        }
        //添加模块
        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);
        }
        private void ShowSDKSetup(MODULE_SYMBOL symbol)
        {
            if (!ModuleConst.NeedSDKDict.ContainsKey(symbol) || isImportDict[symbol] == false)
            {
                return;
            }

            SDKType sdkType  = ModuleConst.NeedSDKDict[symbol];
            bool    hasSetup = sdkManager.HasSetuped(sdkType);

            if (hasSetup)
            {
                GUILayout.Label("SDK:" + sdkType.ToString() +
                                " has setuped", GUIHelper.MakeHeader(30), GUILayout.Width(200));
            }
            else
            {
                if (!ModuleControl.isDevelopMode)
                {
                    if (GUILayout.Button("Need Setup", GUILayout.Width(100)))
                    {
                        if (EditorUtility.DisplayDialog("Setup SDK",
                                                        "Do you want to setup " + sdkType.ToString() + " ?"
                                                        , "OK", "NO"))
                        {
                            sdkManager.SetupSDK(sdkType);
                        }
                    }
                }
                else
                {
                    GUILayout.Label("SDK:" + sdkType.ToString() +
                                    " no setuped", GUIHelper.MakeHeader(30), GUILayout.Width(200));
                }
            }
        }
        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");
            }
        }
        //移除预编译宏
        public static void RemoveSymbol(MODULE_SYMBOL symbol)
        {
            string symbolName = ModuleConst.SymbolName[symbol];

            RemoveSymbol(symbolName);
        }
 //检查是否存在该模块
 public static bool ContainSymbol(MODULE_SYMBOL symbol)
 {
     return(ContainSymbol(ModuleConst.SymbolName[symbol]));
 }
Beispiel #7
0
 /// <summary>
 /// 获取模块备份路径
 /// </summary>
 /// <param name="symbol"></param>
 /// <returns></returns>
 public static string GetSymbolTempPath(MODULE_SYMBOL symbol)
 {
     return(Path.Combine(PathConfig.ResetCoreBackUpPath, SymbolFoldNames[symbol]));
 }