Ejemplo n.º 1
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");
            }
        }