Однако я продолжаю получать одну и ту же ошибку независимо от того, пытаюсь ли я использовать мобильное устройство или Unity:
Код: Выделить всё
Exception: Failed
GPmanager.Start () (at Assets/Scripts/menu/GPmanager.cs:25)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+c.b__7_0 (System.Object state) (at :0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at :0)
UnityEngine.UnitySynchronizationContext.Exec () (at :0)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at :0)
GPManager (как показано в уроке):
Код: Выделить всё
public string Token;
public string Error;
void Awake()
{
PlayGamesPlatform.Activate();
}
async void Start()
{
await UnityServices.InitializeAsync();
await LoginGooglePlayGames();
await SignInWithGooglePlayGamesAsync(Token);
}
//Fetch the Token / Auth code
public Task LoginGooglePlayGames()
{
var tcs = new TaskCompletionSource();
PlayGamesPlatform.Instance.Authenticate((success) =>
{
if (success == SignInStatus.Success)
{
Debug.Log("Login with Google Play games successful.");
PlayGamesPlatform.Instance.RequestServerSideAccess(true, code =>
{
Debug.Log("Authorization code: " + code);
Token = code;
// This token serves as an example to be used for SignInWithGooglePlayGames
tcs.SetResult(null);
});
}
else
{
Error = "Failed to retrieve Google play games authorization code";
Debug.Log("Login Unsuccessful");
tcs.SetException(new Exception("Failed"));
}
});
return tcs.Task;
}
async Task SignInWithGooglePlayGamesAsync(string authCode)
{
try
{
await AuthenticationService.Instance.SignInWithGooglePlayGamesAsync(authCode);
Debug.Log($"PlayerID: {AuthenticationService.Instance.PlayerId}"); //Display the Unity Authentication PlayerID
Debug.Log("SignIn is successful.");
}
catch (AuthenticationException ex)
{
// Compare error code to AuthenticationErrorCodes
// Notify the player with the proper error message
Debug.LogException(ex);
}
catch (RequestFailedException ex)
{
// Compare error code to CommonErrorCodes
// Notify the player with the proper error message
Debug.LogException(ex);
}
}
Есть идеи?
Unity — 2022.3.18f1
Плагин GPS — v11.01
Unity Auth — 3.3.1
Подробнее здесь: https://stackoverflow.com/questions/784 ... play-games
Мобильная версия