Пример #1
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);
        }
Пример #2
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.");
        }