Exemple #1
0
        void OnGUI()
        {
            try
            {
                GUI.skin = PlayFabEditorHelper.uiStyle;

                GUILayout.BeginVertical();

                //Run all updaters prior to drawing;
                PlayFabEditorSettings.Update();

                PlayFabEditorHeader.DrawHeader();


                GUI.enabled = blockingRequests.Count > 0 || EditorApplication.isCompiling ? false : true;

                if (PlayFabEditorDataService.isDataLoaded)
                {
                    if (PlayFabEditorAuthenticate.IsAuthenticated())
                    {
                        //Try catching to avoid Draw errors that do not actually impact the functionality
                        try
                        {
                            PlayFabEditorMenu.DrawMenu();

                            switch (PlayFabEditorMenu._menuState)
                            {
                            case PlayFabEditorMenu.MenuStates.Sdks:
                                PlayFabEditorSDKTools.DrawSdkPanel();
                                break;

                            case PlayFabEditorMenu.MenuStates.Settings:
                                PlayFabEditorSettings.DrawSettingsPanel();
                                PlayFabEditorSettings.After();
                                break;

                            case PlayFabEditorMenu.MenuStates.Help:
                                PlayFabEditorHelpMenu.DrawHelpPanel();
                                break;

                            case PlayFabEditorMenu.MenuStates.Data:
                                PlayFabEditorDataMenu.DrawDataPanel();
                                break;

                            default:
                                break;
                            }
                        }
                        catch //(Exception ex)
                        {
                            //RaiseStateUpdate(EdExStates.OnError, ex.Message);
                        }
                    }
                    else
                    {
                        PlayFabEditorAuthenticate.DrawAuthPanels();
                    }

                    GUILayout.BeginVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1"), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();


                    // help tag at the bottom of the help menu.
                    if (PlayFabEditorMenu._menuState == PlayFabEditorMenu.MenuStates.Help)
                    {
                        GUILayout.BeginVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1"));
                        GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"));
                        GUILayout.FlexibleSpace();
                        EditorGUILayout.LabelField(string.Format("PlayFab Editor Extensions: {0}", PlayFabEditorHelper.EDEX_VERSION), PlayFabEditorHelper.uiStyle.GetStyle("versionText"));
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();

                        //TODO Add plugin upgrade option here (if available);


                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("VIEW DOCUMENTATION", PlayFabEditorHelper.uiStyle.GetStyle("textButton")))
                        {
                            Application.OpenURL("https://github.com/PlayFab/UnityEditorExtensions");
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("REPORT ISSUES", PlayFabEditorHelper.uiStyle.GetStyle("textButton")))
                        {
                            Application.OpenURL("https://github.com/PlayFab/UnityEditorExtensions/issues");
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();

                        if (!string.IsNullOrEmpty(PlayFabEditorHelper.EDITOR_ROOT))
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("UNINSTALL ", PlayFabEditorHelper.uiStyle.GetStyle("textButton")))
                            {
                                if (EditorUtility.DisplayDialog("Confirm Editor Extensions Removal", "This action will remove PlayFab Editor Extensions from the current project.", "Confirm", "Cancel"))
                                {
                                    try
                                    {
                                        PlayFabEditor.window.Close();
                                        var edExRoot = new DirectoryInfo(PlayFabEditorHelper.EDITOR_ROOT);

                                        FileUtil.DeleteFileOrDirectory(edExRoot.Parent.FullName);
                                        PlayFabEditorDataService.RemoveEditorPrefs();


                                        AssetDatabase.Refresh();
                                    }
                                    catch (Exception ex)
                                    {
                                        RaiseStateUpdate(EdExStates.OnError, ex.Message);
                                        PlayFabServices();
                                    }
                                }
                            }
                            GUILayout.FlexibleSpace();
                            GUILayout.EndHorizontal();
                            GUILayout.EndVertical();
                        }
                    }

                    GUILayout.EndVertical();

                    PruneBlockingRequests();

                    try
                    {
                        Repaint();
                    }
                    catch //(Exception ex)
                    {
                        //RaiseStateUpdate(EdExStates.OnError, ex.Message);
                    }
                }
            }
            catch //(Exception ex)
            {
                //RaiseStateUpdate(EdExStates.OnError, ex.Message);
            }
        }
        void OnGUI()
        {
            try
            {
                GUI.skin = PlayFabEditorHelper.uiStyle;

                GUILayout.BeginVertical();

                //Run all updaters prior to drawing;
                PlayFabEditorSettings.Update();
                PlayFabEditorPackageManager.Update();
                PlayFabEditorHeader.DrawHeader();


                GUI.enabled = blockingRequests.Count > 0 || EditorApplication.isCompiling ? false : true;

                if (PlayFabEditorDataService.isDataLoaded)
                {
                    if (PlayFabEditorAuthenticate.IsAuthenticated())
                    {
                        //Try catching to avoid Draw errors that do not actually impact the functionality
                        try
                        {
                            PlayFabEditorMenu.DrawMenu();

                            switch (PlayFabEditorMenu._menuState)
                            {
                            case PlayFabEditorMenu.MenuStates.Sdks:
                                PlayFabEditorSDKTools.DrawSdkPanel();
                                break;

                            case PlayFabEditorMenu.MenuStates.Settings:
                                PlayFabEditorSettings.DrawSettingsPanel();
                                PlayFabEditorSettings.After();
                                break;

                            case PlayFabEditorMenu.MenuStates.Help:
                                PlayFabEditorHelpMenu.DrawHelpPanel();
                                break;

                            case PlayFabEditorMenu.MenuStates.Data:
                                PlayFabEditorDataMenu.DrawDataPanel();
                                break;

                            case PlayFabEditorMenu.MenuStates.Tools:
                                PlayFabEditorToolsMenu.DrawToolsPanel();
                                break;

                            default:
                                break;
                            }
                        }
                        catch //(Exception ex)
                        {
                            //RaiseStateUpdate(EdExStates.OnError, ex.Message);
                        }
                    }
                    else
                    {
                        PlayFabEditorAuthenticate.DrawAuthPanels();
                    }

                    GUILayout.BeginVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1"), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();


                    // help tag at the bottom of the help menu.
                    if (PlayFabEditorMenu._menuState == PlayFabEditorMenu.MenuStates.Help)
                    {
                        GUILayout.BeginVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1"));
                        GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"));
                        GUILayout.FlexibleSpace();
                        EditorGUILayout.LabelField(string.Format("PlayFab Editor Extensions: {0}", PlayFabEditorHelper.EDEX_VERSION), PlayFabEditorHelper.uiStyle.GetStyle("versionText"));
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();

                        //TODO Add plugin upgrade option here (if available);
                        if (ShowEdExUpgrade())
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("UPGRADE EDEX", PlayFabEditorHelper.uiStyle.GetStyle("textButtonOr")))
                            {
                                UpgradeEdEx();
                            }
                            GUILayout.FlexibleSpace();
                            GUILayout.EndHorizontal();
                        }


                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("VIEW DOCUMENTATION", PlayFabEditorHelper.uiStyle.GetStyle("textButton")))
                        {
                            Application.OpenURL("https://github.com/PlayFab/UnityEditorExtensions");
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("REPORT ISSUES", PlayFabEditorHelper.uiStyle.GetStyle("textButton")))
                        {
                            Application.OpenURL("https://github.com/PlayFab/UnityEditorExtensions/issues");
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();

                        if (!string.IsNullOrEmpty(PlayFabEditorHelper.EDEX_ROOT))
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("UNINSTALL ", PlayFabEditorHelper.uiStyle.GetStyle("textButton")))
                            {
                                RemoveEdEx();
                            }
                            GUILayout.FlexibleSpace();
                            GUILayout.EndHorizontal();
                            GUILayout.EndVertical();
                        }
                    }

                    GUILayout.EndVertical();

                    PruneBlockingRequests();

                    try
                    {
                        Repaint();
                    }
                    catch //(Exception ex)
                    {
                        //RaiseStateUpdate(EdExStates.OnError, ex.Message);
                    }
                }
            }
            catch //(Exception ex)
            {
                //RaiseStateUpdate(EdExStates.OnError, ex.Message);
            }
        }