コード例 #1
0
 private static void OnLoginButtonClicked()
 {
     PlayFabEditorApi.Login(new LoginRequest()
     {
         DeveloperToolProductName    = PlayFabEditorHelper.EDEX_NAME,
         DeveloperToolProductVersion = PlayFabEditorHelper.EDEX_VERSION,
         Email    = _userEmail,
         Password = _userPass
     }, (result) =>
     {
         PlayFabEditorPrefsSO.Instance.DevAccountToken = result.DeveloperClientToken;
         PlayFabEditorPrefsSO.Instance.DevAccountEmail = _userEmail;
         PlayFabEditorDataService.RefreshStudiosList();
         PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogin);
         PlayFabEditorPrefsSO.Save();
         PlayFabEditorMenu._menuState = PlayFabEditorMenu.MenuStates.Sdks;
     }, (error) =>
     {
         if ((int)error.Error == 1246 || error.ErrorMessage.Contains("TwoFactor"))
         {
             // pop 2FA dialog
             PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnWarning, "This account requires 2-Factor Authentication.");
             activeState = PanelDisplayStates.TwoFactorPrompt;
         }
         else
         {
             PlayFabEditorHelper.SharedErrorCallback(error);
         }
     });
 }
コード例 #2
0
 public static void RefreshStudiosList(bool onlyIfNull = false)
 {
     if (string.IsNullOrEmpty(PlayFabEditorPrefsSO.Instance.DevAccountToken))
     {
         return; // Can't load studios when not logged in
     }
     if (onlyIfNull && PlayFabEditorPrefsSO.Instance.StudioList != null)
     {
         return; // Don't spam load this, only load it the first time
     }
     if (PlayFabEditorPrefsSO.Instance.StudioList != null)
     {
         PlayFabEditorPrefsSO.Instance.StudioList.Clear();
     }
     PlayFabEditorApi.GetStudios(new GetStudiosRequest(), (getStudioResult) =>
     {
         if (PlayFabEditorPrefsSO.Instance.StudioList == null)
         {
             PlayFabEditorPrefsSO.Instance.StudioList = new List <Studio>();
         }
         foreach (var eachStudio in getStudioResult.Studios)
         {
             PlayFabEditorPrefsSO.Instance.StudioList.Add(eachStudio);
         }
         PlayFabEditorPrefsSO.Instance.StudioList.Add(Studio.OVERRIDE);
         PlayFabEditorPrefsSO.Save();
     }, PlayFabEditorHelper.SharedErrorCallback);
 }
コード例 #3
0
        private static void OnRegisterClicked()
        {
            if (_userPass != _userPass2)
            {
                Debug.LogError("PlayFab developer account passwords must match.");
                return;
            }

            PlayFabEditorApi.RegisterAccount(new RegisterAccountRequest()
            {
                DeveloperToolProductName    = PlayFabEditorHelper.EDEX_NAME,
                DeveloperToolProductVersion = PlayFabEditorHelper.EDEX_VERSION,
                Email      = _userEmail,
                Password   = _userPass,
                StudioName = _studio
            }, (result) =>
            {
                PlayFabEditorPrefsSO.Instance.DevAccountToken = result.DeveloperClientToken;
                PlayFabEditorPrefsSO.Instance.DevAccountEmail = _userEmail;

                PlayFabEditorDataService.RefreshStudiosList();

                PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogin);
                PlayFabEditorMenu._menuState = PlayFabEditorMenu.MenuStates.Sdks;
                PlayFabEditorPrefsSO.Save();
            }, PlayFabEditorHelper.SharedErrorCallback);
        }
コード例 #4
0
        private static void UpdateScriptableObject()
        {
            var playfabSettingsType = PlayFabEditorSDKTools.GetPlayFabSettings();

            if (playfabSettingsType == null || !PlayFabEditorSDKTools.IsInstalled || !PlayFabEditorSDKTools.isSdkSupported)
            {
                return;
            }

            var props = playfabSettingsType.GetProperties();

            foreach (var property in props)
            {
                switch (property.Name.ToLowerInvariant())
                {
                case "productionenvironmenturl":
                    property.SetValue(null, PlayFabEditorHelper.TITLE_ENDPOINT, null); break;
                }
            }

            var getSoMethod = playfabSettingsType.GetMethod("GetSharedSettingsObjectPrivate", BindingFlags.NonPublic | BindingFlags.Static);

            if (getSoMethod != null)
            {
                var so = getSoMethod.Invoke(null, new object[0]) as ScriptableObject;
                if (so != null)
                {
                    EditorUtility.SetDirty(so);
                }
            }
            PlayFabEditorPrefsSO.Save();
            AssetDatabase.SaveAssets();
        }
コード例 #5
0
        private static void UpdateScriptableObject()
        {
            var playfabSettingsType = PlayFabEditorSDKTools.PlayFabSettings;

            if (playfabSettingsType == null || !PlayFabEditorSDKTools.IsInstalled)
            {
                return;
            }

            EditorUtility.SetDirty(playfabSettingsType);
            PlayFabEditorPrefsSO.Save();
            AssetDatabase.SaveAssets();
        }
 private static void OnContinueButtonClicked()
 {
     PlayFabEditorApi.Login(new LoginRequest()
     {
         DeveloperToolProductName    = PlayFabEditorHelper.EDEX_NAME,
         DeveloperToolProductVersion = PlayFabEditorHelper.GetApiVersion(ApiCategory.editorextensions),
         TwoFactorAuth = _2FaCode,
         Email         = _userEmail,
         Password      = _userPass
     }, (result) =>
     {
         PlayFabEditorPrefsSO.Instance.DevAccountToken = result.DeveloperClientToken;
         PlayFabEditorPrefsSO.Instance.DevAccountEmail = _userEmail;
         PlayFabEditorDataService.RefreshStudiosList();
         PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogin);
         PlayFabEditorPrefsSO.Save();
     }, PlayFabEditorHelper.SharedErrorCallback);
 }
コード例 #7
0
        public static void Logout()
        {
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogout);

            PlayFabEditorApi.Logout(new LogoutRequest
            {
                DeveloperClientToken = PlayFabEditorPrefsSO.Instance.DevAccountToken
            }, null, PlayFabEditorHelper.SharedErrorCallback);

            _userPass  = string.Empty;
            _userPass2 = string.Empty;

            activeState = PanelDisplayStates.Login;

            PlayFabEditorPrefsSO.Instance.StudioList      = null;
            PlayFabEditorPrefsSO.Instance.DevAccountToken = string.Empty;
            PlayFabEditorPrefsSO.Save();

            PlayFabEditorPrefsSO.Instance.TitleDataCache.Clear();
            PlayFabEditorDataService.SaveEnvDetails();
        }
コード例 #8
0
        public static void DrawAuthPanels()
        {
            //capture enter input for login
            var e = Event.current;

            if (e.type == EventType.KeyUp && e.keyCode == KeyCode.Return)
            {
                switch (activeState)
                {
                case PanelDisplayStates.Login:
                    OnLoginButtonClicked();
                    break;

                case PanelDisplayStates.Register:
                    OnRegisterClicked();
                    break;

                case PanelDisplayStates.TwoFactorPrompt:
                    OnContinueButtonClicked();
                    break;
                }
            }

            if (PlayFabEditorHelper.uiStyle == null)
            {
                return;
            }

            if (activeState == PanelDisplayStates.TwoFactorPrompt)
            {
                using (new UnityVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")))
                {
                    using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")))
                        EditorGUILayout.LabelField("Enter your 2-factor authorization code.", PlayFabEditorHelper.uiStyle.GetStyle("cGenTxt"), GUILayout.MinWidth(EditorGUIUtility.currentViewWidth));

                    using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")))
                    {
                        GUILayout.FlexibleSpace();
                        _2FaCode = EditorGUILayout.TextField(_2FaCode, PlayFabEditorHelper.uiStyle.GetStyle("TextField"), GUILayout.MinHeight(25), GUILayout.MinWidth(200));
                        GUILayout.FlexibleSpace();
                    }

                    using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("labelStyle")))
                    {
                        var buttonWidth = 100;
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("CONTINUE", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MinHeight(32), GUILayout.MaxWidth(buttonWidth)))
                        {
                            OnContinueButtonClicked();
                            _2FaCode = string.Empty;
                        }
                        GUILayout.FlexibleSpace();
                    }

                    using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("labelStyle")))
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("CANCEL", PlayFabEditorHelper.uiStyle.GetStyle("textButton")))
                        {
                            activeState = PanelDisplayStates.Login;
                        }
                        GUILayout.FlexibleSpace();
                    }
                }
                return;
            }

            if (!string.IsNullOrEmpty(PlayFabEditorPrefsSO.Instance.DevAccountEmail) && !isInitialized)
            {
                _userEmail = PlayFabEditorPrefsSO.Instance.DevAccountEmail;
                PlayFabEditorPrefsSO.Save();
                isInitialized = true;
            }
            else if (!isInitialized)
            {
                activeState   = PanelDisplayStates.Register;
                isInitialized = true;
            }

            using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")))
                EditorGUILayout.LabelField("Welcome to PlayFab!", PlayFabEditorHelper.uiStyle.GetStyle("titleLabel"), GUILayout.MinWidth(EditorGUIUtility.currentViewWidth));

            if (activeState == PanelDisplayStates.Login)
            {
                // login mode, this state either logged out, or did not have auto-login checked.
                DrawLogin();
            }
            else if (activeState == PanelDisplayStates.Register)
            {
                // register mode
                DrawRegister();
            }
            else
            {
                DrawRegister();
            }

            using (new UnityVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")))
            {
                using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")))
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("VIEW README", PlayFabEditorHelper.uiStyle.GetStyle("textButton")))
                    {
                        Application.OpenURL("https://github.com/PlayFab/UnityEditorExtensions#setup");
                    }
                    GUILayout.FlexibleSpace();
                }
            }
        }