public static IEnumerator ExecuteImport(ConvertSetting s) { downloadSuccess = false; yield return(EditorCoroutineRunner.StartCoroutine(ExecuteDownload(s))); if (!downloadSuccess) { yield break; } CreateAssetsJob createAssetsJob = new CreateAssetsJob(s); // Generate Code if type script is not found. Type assetType; if (s.isEnum || !CsvConvert.TryGetTypeWithError(s.className, out assetType, s.checkFullyQualifiedName, dialog: false)) { GlobalCCSettings gSettings = CCLogic.GetGlobalSettings(); GenerateOneCode(s, gSettings); if (!s.isEnum) { EditorUtility.DisplayDialog( "Code Generated", "Please reimport for creating assets after compiling", "ok" ); } } // Create Assets else { createAssetsJob.Execute(); } // AfterImport 処理 for (int i = 0; i < s.executeAfterImport.Count; i++) { var afterSettings = s.executeAfterImport[i]; if (afterSettings != null) { yield return(EditorCoroutineRunner.StartCoroutine(ExecuteImport(afterSettings))); } } }
private void OnGUI() { GUILayout.Space(6f); ConvertSetting[] settings = null; if (cachedAllSettings != null) { settings = cachedAllSettings; } // 検索ボックスを表示 GUILayout.BeginHorizontal(); searchTxt = SearchField(searchTxt); searchTxt = searchTxt.ToLower(); GUILayout.EndHorizontal(); if (settings != null) { scrollPosition = GUILayout.BeginScrollView(scrollPosition); for (int i = 0; i < settings.Length; i++) { var s = settings[i]; // 設定が削除されている場合などに対応 if (s == null) { continue; } // 検索ワードチェック if (!string.IsNullOrEmpty(searchTxt)) { if (s.tableGenerate) { if (!searchTxt.IsSubsequence(s.tableAssetName.ToLower())) { continue; } } else { if (!searchTxt.IsSubsequence(s.className.ToLower())) { continue; } } } GUILayout.BeginHorizontal("box"); #if ODIN_INSPECTOR // ------------------------------ // 設定を複製ボタン. // ------------------------------ if (GUILayout.Button("+", GUILayout.Width(20))) { var copied = s.Copy(); var window = CCSettingsEditWindow.OpenWindow(); window.SetNewSettings(copied, s.GetDirectoryPath()); GUIUtility.ExitGUI(); } // ------------------------------ // 設定を編集ボタン. // ------------------------------ var edit = EditorGUIUtility.Load("editicon.sml") as Texture2D; if (GUILayout.Button(edit, GUILayout.Width(20))) { var window = CCSettingsEditWindow.OpenWindow(); window.SetSettings(s); GUIUtility.ExitGUI(); } #endif // ------------------------------ // テーブル名 (enum の場合は enum名) を表示. // クリックして、設定ファイルに飛べるようにする. // ------------------------------ if (s.tableGenerate) { if (GUILayout.Button(s.tableAssetName, "Label")) { EditorGUIUtility.PingObject(s.GetInstanceID()); GUIUtility.ExitGUI(); } } else { if (GUILayout.Button(s.className, "Label")) { EditorGUIUtility.PingObject(s.GetInstanceID()); GUIUtility.ExitGUI(); } } // ------------------------------ // GS Plugin 使う場合のボタン. // // Import ボタン // Open ボタン // ------------------------------ if (s.useGSPlugin) { if (GUILayout.Button("Import", GUILayout.Width(110))) { EditorCoroutineRunner.StartCoroutine(ExecuteImport(s)); GUIUtility.ExitGUI(); } // GS Plugin を使う場合は Open ボタンを用意する. if (s.useGSPlugin) { if (GUILayout.Button("Open", GUILayout.Width(80)) && !isDownloading) { GSUtils.OpenURL(s.sheetID, s.gid); GUIUtility.ExitGUI(); } } if (s.verboseBtn) { if (GUILayout.Button("DownLoad", GUILayout.Width(110))) { EditorCoroutineRunner.StartCoroutine(ExecuteDownload(s)); GUIUtility.ExitGUI(); } } } // ------------------------------ // コード生成ボタン. // v0.1.2 からは Import に置き換え. // ------------------------------ if (s.verboseBtn) { GUI.enabled = s.canGenerateCode; if (GUILayout.Button("Generate Code", GUILayout.Width(110)) && !isDownloading) { GlobalCCSettings gSettings = CCLogic.GetGlobalSettings(); isDownloading = true; GenerateOneCode(s, gSettings); isDownloading = false; GUIUtility.ExitGUI(); } } // ------------------------------ // アセット生成ボタン. // v0.1.2 からは Import に置き換え. // ------------------------------ if (s.verboseBtn) { GUI.enabled = s.canCreateAsset; if (GUILayout.Button("Create Assets", GUILayout.Width(110)) && !isDownloading) { CreateAssetsJob createAssetsJob = new CreateAssetsJob(s); createAssetsJob.Execute(); GUIUtility.ExitGUI(); } } GUI.enabled = true; // ------------------------------ // 成果物参照まど. // ------------------------------ { Object outputRef = null; if (s.join) { outputRef = s.targetTable; } else { string mainOutputPath = CCLogic.GetMainOutputPath(s); if (mainOutputPath != null) { outputRef = AssetDatabase.LoadAssetAtPath <Object>(mainOutputPath); } } EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(outputRef, typeof(Object), false, GUILayout.Width(100)); EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.BeginHorizontal("box"); if (GUILayout.Button("Generate All Codes", "LargeButtonMid") && !isDownloading) { GlobalCCSettings gSettings = CCLogic.GetGlobalSettings(); isDownloading = true; GenerateAllCode(settings, gSettings); isDownloading = false; GUIUtility.ExitGUI(); } if (GUILayout.Button("Create All Assets", "LargeButtonMid") && !isDownloading) { GlobalCCSettings gSettings = CCLogic.GetGlobalSettings(); isDownloading = true; CreateAllAssets(settings, gSettings); isDownloading = false; GUIUtility.ExitGUI(); } GUILayout.EndHorizontal(); } }