question

deaverinc avatar image
deaverinc asked

Not getting account information on first try after login

hey, this is my first time using playfab. i am trying to create an account and then retrieve the account information but it fails on the first try. i can retry and get the account information. i am new at this and i dont understand why i am getting an exception. i am successfully logging in after createing an account. when i try to get the payload for the first time is when i get the error. there are other buttons in the program that i can hit to get the account information and they are successful. the buttons simply call the GetAccountInfo function. here is my code and errors that i receive. i am assuming that this is the correct forum to ask. any help would be aprreciated. thanks.

private static AccountInfo instance;

public static AccountInfo Instance

{

get { return instance; }

set { instance = value; }

}

[SerializeField]

private GetPlayerCombinedInfoResultPayload info;

public GetPlayerCombinedInfoResultPayload Info

{

get { return info; }

set { info = value; }

}

public static void LoginSuccessStartAccountInfo(string playfabId) <--- THIS IS CALLED AFTER LOGIN

{

string PlayFabId = playfabId;

AccountInfo.GetAccountInfo();

Database.UpdateDatabase();

}

public static void GetAccountInfo(string playfabId)

{

GetPlayerCombinedInfoRequestParams paramInfo = new GetPlayerCombinedInfoRequestParams

{

GetTitleData = true,

GetUserInventory = true,

GetUserAccountInfo = true,

GetUserVirtualCurrency = true,

GetPlayerProfile = true,

GetPlayerStatistics = true,

GetUserData = true,

GetUserReadOnlyData = true

};

GetPlayerCombinedInfoRequest request = new GetPlayerCombinedInfoRequest()

{

PlayFabId = playfabId,

InfoRequestParameters = paramInfo

};

PlayFabClientAPI.GetPlayerCombinedInfo(request, OnGotAccountInfo, GameFunctions.PlayFabAPIFailure);

}

static void OnGotAccountInfo(GetPlayerCombinedInfoResult result)

{

Instance.Info = result.InfoResultPayload; <--- THE ERRORS OCCUR HERE

AddCards();

}

}

THESE ARE THE ERRORS I GET AFTER INITIAL LOGIN:

NullReferenceException: Object reference not set to an instance of an object AccountInfo.OnGotAccountInfo (PlayFab.ClientModels.GetPlayerCombinedInfoResult result) (at Assets/Scripts/PlayFab/AccountInfo.cs:163) PlayFab.Internal.PlayFabHttp+<>c__DisplayClass23_0`1[TResult].<_MakeApiCall>b__1 () (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabHTTP.cs:215) PlayFab.Internal.PlayFabUnityHttp.OnResponse (System.String response, PlayFab.Internal.CallRequestContainer reqContainer) (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:207) UnityEngine.Debug:LogException(Exception) PlayFab.Internal.PlayFabUnityHttp:OnResponse(String, CallRequestContainer) (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:211) PlayFab.Internal.<Post>d__12:MoveNext() (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:159) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

deaverinc avatar image deaverinc commented ·

i actually came up with a work around for this problem but i would still like to know why it is happening. my work around code is here:

if (result == null)

{

GetAccountInfo();

}

else

{

try

{

Instance.Info = result.InfoResultPayload;

AddCards();

}

catch (Exception e)

{

Debug.LogException(e);

GetAccountInfo();

}

}

i just have it retry everytime it fails which is almost always, but not always and the retry works everytime. i dont understand it. :-(

0 Likes 0 ·

1 Answer

·
Seth Du avatar image
Seth Du answered

I cannot dig into this issue as I am not able to distinguish if the classes/variables are self-defined in the partial code you have provided. If possible, please submit a complete script for us to troubleshoot, and remember to remove any personal information.

To be clear, for most Login API, you may define InfoRequestParameters in the request for login while getting account information at the same time. GetPlayerCombinedInfoResultPayload class contains plenty of player information and if you only need UserAccountInfo, simply define a UserAccountInfo variable.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

deaverinc avatar image deaverinc commented ·

thats alot of code so i am going to go with the work around. thank you for your time

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.