Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1.     #region Login
  2.     public void Login(Action doneCallback)
  3.     {
  4.         Login_GoogleAuthenticate(doneCallback);
  5.     }
  6.     private void Login_GoogleAuthenticate(Action doneCallback)
  7.     {
  8.         Social.localUser.Authenticate((success, error) =>
  9.         {
  10.             if (success)
  11.             {
  12.                 var serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();
  13.                 Login_PlayfabLogin(serverAuthCode, doneCallback);
  14.             }
  15.             else
  16.                 HandleError("google_auth", error);
  17.         });
  18.     }
  19.     private void Login_PlayfabLogin(string serverAuthCode, Action doneCallback)
  20.     {
  21.         PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
  22.         {
  23.             ServerAuthCode = serverAuthCode,
  24.             CreateAccount = true
  25.         }, (result) =>
  26.         {
  27.             playFabId = result.PlayFabId;
  28.             newlyPlayer = result.NewlyCreated;
  29.             if (newlyPlayer)
  30.                 Login_CreateProfile(doneCallback);
  31.             else
  32.                 Login_GetProfile(doneCallback);
  33.         }, (playFabError) => HandleError("playfab_login", playFabError.GenerateErrorReport()));
  34.     }
  35.     private void Login_CreateProfile(Action doneCallback)
  36.     {
  37.         PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
  38.         {
  39.             FunctionName = "createProfile"
  40.         }, (result) =>
  41.         {
  42.             Login_GetProfile(doneCallback);
  43.         }, (error) => HandleError("create_profile", error.GenerateErrorReport()));
  44.     }
  45.     private void Login_GetProfile(Action doneCallback)
  46.     {
  47.         PlayFabClientAPI.GetUserReadOnlyData(new GetUserDataRequest(), (result) =>
  48.         {
  49.             profile = ParseProfile(result.Data);
  50.             doneCallback();
  51.         }, (error) => HandleError("get_profile", error.GenerateErrorReport()));
  52.     }
  53.     #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement