Skip to content

Commit

Permalink
Fix null achievement array
Browse files Browse the repository at this point in the history
Need to return if not authenticated, otherwise `mClient.LoadAchievements` will fail with a null achievement array.

Also added a null guard around the callback invocation.

Full error:

```
NullReferenceException: Object reference not set to an instance of an object
GooglePlayGames.PlayGamesPlatform+<LoadAchievements>c__AnonStorey9.<>m__5 (GooglePlayGames.BasicApi.Achievement[] ach)
GooglePlayGames.BasicApi.DummyClient.LoadAchievements (System.Action`1 callback)
GooglePlayGames.PlayGamesPlatform.LoadAchievements (System.Action`1 callback)
UnityEngine.Social.LoadAchievements (System.Action`1 callback)
```
  • Loading branch information
JamesMcMahon committed May 23, 2016
1 parent b9a7314 commit 59a0aa3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,11 @@ public void LoadAchievementDescriptions(Action<IAchievementDescription[]> callba
{
GooglePlayGames.OurUtils.Logger.e(
"LoadAchievementDescriptions can only be called after authentication.");
callback.Invoke(null);
if (callback != null)
{
callback.Invoke(null);
}
return;
}

mClient.LoadAchievements(ach =>
Expand Down

0 comments on commit 59a0aa3

Please sign in to comment.