Example #1
0
        private static async Task <Tuple <int, string> > ExecuteProcess(TextDataConfig.GenerateAssetSetting setting, Mode mode, bool displayConsole)
        {
            var config = TextDataConfig.Instance;

            var arguments = new StringBuilder();

            arguments.AppendFormat("--workspace {0} ", setting.GetTextDataWorkspacePath());

            switch (mode)
            {
            case Mode.Import:
                arguments.Append("--mode import ");
                break;

            case Mode.Export:
                arguments.Append("--mode export ");
                break;
            }

            var processExecute = new ProcessExecute(config.ConverterPath, arguments.ToString())
            {
                Encoding         = Encoding.GetEncoding("Shift_JIS"),
                WorkingDirectory = setting.GetTextDataWorkspacePath(),
                UseShellExecute  = displayConsole,
                Hide             = !displayConsole,
            };

            var result = await processExecute.StartAsync();

            return(Tuple.Create(result.ExitCode, result.Error));
        }
Example #2
0
        // エクセル制御GUI描画.
        private void DrawExcelControlGUI()
        {
            TextDataConfig.GenerateAssetSetting setting = null;

            switch (contentType)
            {
            case ContentType.Embedded:
                setting = config.Embedded;
                break;

            case ContentType.Distribution:
                setting = config.Distribution;
                break;
            }

            EditorLayoutTools.Title("Excel");

            GUILayout.Space(4f);

            var excelFilePath = setting.GetExcelPath();

            var excelFileExists = File.Exists(excelFilePath);

            using (new DisableScope(!excelFileExists))
            {
                if (GUILayout.Button("Open"))
                {
                    TextDataExcel.Open(setting);
                }
            }

            GUILayout.Space(4f);

            var isLock = TextDataExcel.IsExcelFileLocked(setting);

            using (new DisableScope(isLock))
            {
                if (GUILayout.Button("Import"))
                {
                    var nowait = TextDataExcel.Import(contentType, true);

                    UnityConsole.Info("TextData import record finish.");
                }
            }

            GUILayout.Space(4f);

            using (new DisableScope(!excelFileExists))
            {
                if (GUILayout.Button("Export"))
                {
                    var nowait = TextDataExcel.Export(contentType, true);

                    UnityConsole.Info("TextData export record finish.");
                }
            }

            GUILayout.Space(4f);
        }
Example #3
0
        public static bool IsExcelFileLocked(TextDataConfig.GenerateAssetSetting setting)
        {
            var editExcelPath = setting.GetExcelPath();

            if (!File.Exists(editExcelPath))
            {
                return(false);
            }

            return(FileUtility.IsFileLocked(editExcelPath));
        }
Example #4
0
        //----- field -----

        //----- property -----

        //----- method -----

        public static void Open(TextDataConfig.GenerateAssetSetting setting)
        {
            var path = setting.GetExcelPath();

            if (!File.Exists(path))
            {
                Debug.LogError("TextData excel file not found.");
                return;
            }

            using (var process = new Process())
            {
                var processStartInfo = new ProcessStartInfo
                {
                    FileName = path,
                };

                process.StartInfo = processStartInfo;

                //起動.
                process.Start();
            }
        }
Example #5
0
        private static async Task UpdateTextData(TextDataAsset textDataAsset, TextDataConfig.GenerateAssetSetting setting)
        {
            if (textDataAsset == null)
            {
                return;
            }

            var excelPath = setting.GetExcelPath();

            if (!File.Exists(excelPath))
            {
                return;
            }

            var lastUpdate = File.GetLastWriteTime(excelPath).ToUnixTime();

            if (!textDataAsset.UpdateAt.HasValue)
            {
                return;
            }

            if (lastUpdate < textDataAsset.UpdateAt)
            {
                return;
            }

            var languageManager = LanguageManager.Instance;

            var languageInfo = languageManager.Current;

            await TextDataExcel.Export(textDataAsset.ContentType, false);

            TextDataGenerator.Generate(textDataAsset.ContentType, languageInfo);

            UnityConsole.Info("TextData auto updated.");
        }
Example #6
0
        public static async Task Export(ContentType contentType, bool displayConsole)
        {
            var config = TextDataConfig.Instance;

            TextDataConfig.GenerateAssetSetting setting = null;

            switch (contentType)
            {
            case ContentType.Embedded:
                setting = config.Embedded;
                break;

            case ContentType.Distribution:
                setting = config.Distribution;
                break;
            }

            var result = await ExecuteProcess(setting, Mode.Export, displayConsole);

            if (result.Item1 != 0)
            {
                Debug.LogError(result.Item2);
            }
        }