Example #1
0
        //移除模块
        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);
        }
Example #2
0
        //添加模块
        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);
        }
Example #3
0
        //刷新备份文件夹
        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();
        }
Example #4
0
        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");
            }
        }