Exemplo n.º 1
0
        void OnGUI()
        {
            settings = EditorGUILayout.ObjectField("Settings", settings, typeof(GSPluginSettings), false) as GSPluginSettings;

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            if (settings != null)
            {
                // セットされている settings 情報を EditorUserSettings に保存する.
                {
                    string guid;
                    long   localId;

                    if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(settings, out guid, out localId))
                    {
                        if (savedGUID != guid)
                        {
                            // Debug.Log("Save GUID(" + guid + ") at " + SETTINGS_KEY);
                            EditorPrefs.SetString(SETTINGS_KEY, guid);
                            EditorUserSettings.SetConfigValue(SETTINGS_KEY, guid);
                            savedGUID = guid;
                        }
                    }
                }

                for (int i = 0; i < settings.sheets.Length; i++)
                {
                    var sheet = settings.sheets[i];

                    GUILayout.BeginHorizontal("box");
                    GUILayout.Label(sheet.targetPath);

                    if (GUILayout.Button("Download", GUILayout.Width(80)) && !isDownloading)
                    {
                        isDownloading = true;
                        DownloadOne(sheet, settingDir);
                        isDownloading = false;

                        GUIUtility.ExitGUI();
                    }

                    if (GUILayout.Button("Open", GUILayout.Width(80)) && !isDownloading)
                    {
                        GSUtils.OpenURL(sheet.sheetId, sheet.gid);
                        GUIUtility.ExitGUI();
                    }

                    GUILayout.EndHorizontal();
                }

                if (GUILayout.Button("DownloadAll", "LargeButtonMid") && !isDownloading)
                {
                    isDownloading = true;

                    var sheets = new List <GSPluginSettings.Sheet>(settings.sheets);
                    DownloadAll(sheets, settingDir);
                    isDownloading = false;

                    GUIUtility.ExitGUI();
                }
            }

            GUILayout.EndScrollView();
        }
Exemplo n.º 2
0
        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();
            }
        }