I wanted to make achievements and ledarboard for my game, so I decided to use google play games, I did everything in the tutorial, changed the code a little and it works. When I have it loading in unity (made with unity), it displays my google play games profile at the top of the screen, but unfortunately the achievements and leaderboard don't add. Code: googleplayservices.cs:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
public class googleplayservices : MonoBehaviour
{
public void Start()
{
PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
}
internal void ProcessAuthentication(SignInStatus status)
{
if (status == SignInStatus.Success)
{
// Continue with Play Games Services
// print(PlayGamesPlatform.Instance.GetUserId());
PlayGamesPlatform.Instance.RequestServerSideAccess(
/* forceRefreshToken= */ false,
code =>
{
Debug.Log(code);
SignInWithGoogleAsync(code);
});
}
else
{
// Disable your integration with Play Games Services or show a login button
// to ask users to sign-in. Clicking it should call
PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication);
Debug.Log("No");
}
}
public void SignInWithGoogleAsync(string idToken)
{
// Your implementation goes here...
}
public void Osiagniecie(string id, int wartosc)
{
Social.ReportProgress(id, wartosc, (bool success) =>
{
if (success)
{
Debug.Log("Score Update");
}
});
}
public void LeaderBoard(string id, int wartosc)
{
Social.ReportScore(wartosc, id, (bool success) =>
{
if (success)
{
Debug.Log("Score Update");
}
else
{
Debug.Log("Nie udało się przesłać");
}
});
}
}
I tried placing the addition of achievements and to the leaderboard in different places. I did this until I finally went into Android Logcat and while it was supposed to post to the leaderboard I got an error:
2023.06.07 12:22:21.015 6415 6450 Error Unity Must authenticate first
2023.06.07 12:22:21.015 6415 6450 Error Unity UnityEngine.SocialPlatforms.Local:VerifyUser()
2023.06.07 12:22:21.015 6415 6450 Error Unity UnityEngine.SocialPlatforms.Local:ReportScore(Int64, String, Action`1)
2023.06.07 12:22:21.015 6415 6450 Error Unity MoneyScript:AddMoney(Int32)
2023.06.07 12:22:21.015 6415 6450 Error Unity SceneManagerPlus:WinGo()
2023.06.07 12:22:21.015 6415 6450 Error Unity UnityEngine.Events.UnityEvent:Invoke()
2023.06.07 12:22:21.015 6415 6450 Error Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
2023.06.07 12:22:21.015 6415 6450 Error Unity UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
2023.06.07 12:22:21.015 6415 6450 Error Unity UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
2023.06.07 12:22:21.015 6415 6450 Error Unity UnityEngine.EventSystems.StandaloneInputModule:Process()