Esempio n. 1
0
        private void OnEnable()
        {
            HLayout = new EGUIHorizontalLayout();
            var configInput = new EGUIFilePathInput("ConfigPath", EditorPrefs.GetString("GamePlay.UDB.Config", "GamePlay/Editor/Config/Config.ini"), OnConfigPathChanged);

            HLayout.Add(configInput);
            HLayout.Add(new EGUIButton("LoadConfig", () =>
            {
                string filePath = GetConfigFilePath();
                if (File.Exists(filePath))
                {
                    Config.Initialized(filePath);
                    ConfigPropertys = new ConfigPropertys(Config);
                }
            }));

            Config = new Config();
            Config.Initialized(GetConfigFilePath());
            ConfigPropertys = new ConfigPropertys(Config);
        }
Esempio n. 2
0
        //> 转换工作的线程
        void ThreadJob()
        {
            bool exit = false;

            if (!Worker.UrlChecker(ConfigPropertys.GetInUrl(), ConfigPropertys.IsCreateFolder))
            {
                exit = true;
            }
            if (!Worker.UrlChecker(ConfigPropertys.GetOutputDataPath(), ConfigPropertys.IsCreateFolder))
            {
                exit = true;
            }
            if (!Worker.UrlChecker(ConfigPropertys.GetOutputCodePath(), ConfigPropertys.IsCreateFolder) && ConfigPropertys.IsOutputCode)
            {
                exit = true;
            }
            if (exit)
            {
                UnityEngine.Debug.LogError("Some folders don't exist. Please To check and create the folder or open the 'IsCreateFolder' option.");
                return;
            }

            ConfigPropertys   property   = ConfigPropertys;
            CancellationToken token      = CancelController.Token;
            List <string>     excelFiles = new List <string>();
            List <ClassInfo>  codedatas  = new List <ClassInfo>();

            Worker.GetUrlOfXlsxFiles(property.GetInUrl(), property.GetContainerFiles(), property.IsIgnoreCaseFile, ref excelFiles);
            FileCount = excelFiles.Count;

            //> 转换和解析数据
            for (FileIndex = 0; FileIndex < FileCount; FileIndex++)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }

                string url = excelFiles[FileIndex];
                ExcelName  = Path.GetFileName(url);
                RowIndex   = RowCount = 0;
                SheetIndex = SheetCount = 0;

                //> 到处一个excel中所有的sheet
                var collectionData = Worker.ExportFile(
                    url, property.GetOutputDataPath(),
                    property.IsIgnoreCaseSheet,
                    property.IsRemoveEmptyLine,
                    property.GetContainerSheets(),
                    property.StartExportRow,
                    property.GetExportFileSplitSign(),
                    property.GetExportFileExtensionName(),
                    property.IsOutputCode,
                    property.PropertyTypeRow,
                    property.PropertyNameRow,
                    property.DescriptionRow,
                    CancelController,
                    ThreadJobCallback
                    );

                //ThreadJobCallback(SheetCount, SheetCount, SheetName, RowCount, RowCount);

                //> 需要生成的代码数据
                codedatas.AddRange(collectionData.ClassInfos);

                foreach (var v in collectionData.TableContent)
                {
                    File.WriteAllText(string.Format("{0}/{1}", property.GetOutputDataPath(), v.Key), v.Value);
                }
            }

            //> 创建数据
            if (!property.IsOutputCode || token.IsCancellationRequested)
            {
                return;
            }

            Worker.ExportCodeFile(
                property.GetOutputCodePath(),
                property.OutputCodeFileName,
                property.GetCodeNamespace(),
                property.IsDefineUDBDatasetProperty,
                codedatas);
        }