Exemplo n.º 1
0
        void OnEnable()
        {
            string guid = EditorUserSettings.GetConfigValue(SETTINGS_KEY);

            settingPath = AssetDatabase.GUIDToAssetPath(guid);

            if (settingPath != "")
            {
                // Debug.Log("Found prefs settings GUID: " + EditorPrefs.GetString(SETTINGS_KEY));
                settings = AssetDatabase.LoadAssetAtPath <GSPluginSettings>(settingPath);
                // string[] settingGUIDArray = AssetDatabase.FindAssets("t:GSPluginSettings");

                settingDir = Path.GetDirectoryName(settingPath);
            }
            else
            {
                // Debug.Log("Not Found GUID");
            }

            // foreach (string guid in settingGUIDArray) {
            //     string path = AssetDatabase.GUIDToAssetPath(guid);
            //     settings = AssetDatabase.LoadAssetAtPath<GSPluginSettings>(path);
            // }
        }
Exemplo n.º 2
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();
        }