Hi,
Before entering this question, I searched a lot (got stuck for 2 weeks on this problem )
I only aim the google leaderboards functionality in my Unity project. I followed the following steps:
1- Integrated google play games plugin as described in: GitHub - playgameservices/play-games-plugin-for-unity: Google Play Games plugin for Unity
- Created a google play services game entry in my google play developer console and link it to my application (in the same console) with the package id com.o6systems.zray which is in open alpha test.
- I created creditentials and inserted my SHA1 of the keystore / key pair to the google api console.
- I created achievements, 1 scoreboard and get my resources entered to the Window / GooglePlayGames/Setup / Android Setup
The keystore I used is the same that generates the SHA1 code. I entered it in the player settings and its passwords.
My package name is consistent in all platforms (in google api console, google play developer console, in unity everywhere)
I entered my test user to the test users in the console.
2- I entered the following codes for authentication in one of scripts work in my splashscreen scene:
void Start () {
#if UNITY_ANDROID
ConfigureGooglePlay ();
SignIn ();
#endif
}
void ConfigureGooglePlay(){
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
}
void SignIn () {
Social.localUser.Authenticate (success => {
if (success) {
Debug.Log ("Authentication successful");
string userInfo = "Username: " + Social.localUser.userName +
"
User ID: " + Social.localUser.id +
"
IsUnderage: " + Social.localUser.underage;
Debug.Log (userInfo);
// DisplayGPScore();
} else
Debug.Log ("Authentication failed");
});
}
3- In Game Scene, on Game over I post the high score of the user to the leaderboard using ReportScore function
private void OnGameOver(){
...
PostScore(_gm.highScore);
..
DisplayGPScore ();
}
internal void LoadUsersAndDisplay(ILeaderboard lb)
{
// get the user ids
List<string> userIds = new List<string>();
foreach(IScore score in lb.scores) {
userIds.Add(score.userID);
}
// load the profiles and display (or in this case, log)
Social.LoadUsers(userIds.ToArray(), (users) =>
{
string status = "Leaderboard loading: " + lb.title + " count = " +
lb.scores.Length;
foreach(IScore score in lb.scores) {
Debug.Log("" + score.rank + ":" + score.userID);
}
Debug.Log(status);
});
}
public void DisplayGPScore(){
ILeaderboard lb = PlayGamesPlatform.Instance.CreateLeaderboard();
lb.id = ZRayGameManager.WORLD_LEADERBOARD_ID;
lb.LoadScores(ok =>
{
if (ok) {
LoadUsersAndDisplay(lb);
}
else {
Debug.Log("Error retrieving leaderboardi");
}
});
}
public void PostScore(int score){
PlayGamesPlatform.Instance.ReportScore(score, ZRayGameManager.WORLD_LEADERBOARD_ID, (bool success) => {
if(success){
Debug.Log("High score " + score + " posted");
}else{
Debug.Log("High score " + score + " could not be posted");
}
});
}
I simplified the codes (excluded unrelated parts)
I get the following output
I/Unity (15970):
I/Unity (15970): Authentication successful
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): Username: RighthandedTuba240
I/Unity (15970): User ID: g02637898988054749692
I/Unity (15970): IsUnderage: True
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:52 +03:00 DEBUG: Repo
rtScore: score=100, board=CgkIppHPm-wIEAIQCQ
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:52 +03:00 DEBUG: Nati
ve Submitting score: 100 for lb CgkIppHPm-wIEAIQCQ with metadata:
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): User is authenticated
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:52 +03:00 DEBUG: Load
Scores, board=GooglePlayGames.PlayGamesLeaderboard callback is System.Action`1[S
ystem.Boolean]
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:52 +03:00 DEBUG: Invo
king user callback on game thread
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): High score 100 posted
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:55 +03:00 DEBUG: Ente
ring internal callback for LeaderboardManager#InternalFetchCallback
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:47:10 +03:00 DEBUG: Star
ting Auth Transition. Op: SIGN_OUT status: ERROR_NOT_AUTHORIZED
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:47:10 +03:00 DEBUG: Ente
ring internal callback for LeaderboardManager#InternalFetchSummaryCallback
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
W/Unity (15970): !!! [Play Games Plugin DLL] 07/17/16 18:47:10 +03:00 WARNING:
Error returned from fetchScoreSummary: GooglePlayGames.Native.PInvoke.FetchScor
eSummaryResponse
W/Unity (15970):
W/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
W/Unity (15970):
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:47:10 +03:00 DEBUG: Invo
king user callback on game thread
I/Unity (15970):
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (15970):
I/Unity (15970): Error retrieving leaderboardi
Conclusions:
-
The user CAN authenticate because the method Sign In() tells Authentication Successful and prints out the user information.
-
The user CAN post his / her score to the scoreboard, because the PostScore method tells “High Score 100 posted”
-
The user CANNOT display scoreboard scores, with an error of
W/Unity (15970): !!! [Play Games Plugin DLL] 07/17/16 18:47:10 +03:00 WARNING:
Error returned from fetchScoreSummary: GooglePlayGames.Native.PInvoke.FetchScor
eSummaryResponse
I can not find any setting of the scoreboard in console, to give the user access to this scoreboard etc.
Please help!! I am stuck here for 2 weeks (but there is improvement, I was not able to sign in 3 days ago)