Unity-尝试使用GooglePlay服务登录播放器到GooglePlay



im试图使用GooglePlay服务将玩家登录到GooglePlay。该应用程序已发布。开始游戏时,你应该自动登录GooglePlay,但什么都没发生。这是我使用的代码。如果有人能在这个问题上帮助我,我将不胜感激。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
using GooglePlayGames.BasicApi;

public class GooglePlayServices : MonoBehaviour
{
void Start()
{
Initialize();
}
private void Initialize()
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.RequestServerAuthCode(false).
Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
SignInUserWithPlayGames();
}
void SignInUserWithPlayGames()
{
PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptOnce, (success) =>
{
switch(success)
{
case SignInStatus.Success:
Debug.Log("Signed in Player successfully");
break;
default:
Debug.Log("Login failed");
break;
}
});
}
public void SignInByHand()
{
PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptAlways, (success) =>
{
});
}
public void SignOut()
{
PlayGamesPlatform.Instance.SignOut();
}
}
private void Initialize()
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestServerAuthCode(false).Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
SignInUserWithPlayGames();
}
void SignInUserWithPlayGames()
{
if (!Social.localUser.authenticated)
{
Social.localUser.Authenticate(success => {
if(success)
{
// signed in
}
});
}
}

尝试使用社交而不是直接调用Google Play插件。只有当我需要其他社交平台没有的特定功能时,我才会直接调用插件。

最新更新