// エクセル制御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); }
public static bool IsExcelFileLocked(TextDataConfig.GenerateAssetSetting setting) { var editExcelPath = setting.GetExcelPath(); if (!File.Exists(editExcelPath)) { return(false); } return(FileUtility.IsFileLocked(editExcelPath)); }
//----- 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(); } }
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."); }