C# Google Play服务创建基于回合的多人比赛问题
问题 我在unity3D中使用谷歌游戏服务创建基于回合的多人比赛时遇到了问题C# Google Play服务创建基于回合的多人比赛问题,c#,android,unity3d,google-play-services,multiplayer,C#,Android,Unity3d,Google Play Services,Multiplayer,问题 我在unity3D中使用谷歌游戏服务创建基于回合的多人比赛时遇到了问题 PlayGamesPlatform.Activate()成功初始化PlayGamesPlatform。但是,它不会初始化IPlayGamesClient或基于iTunes的多玩家客户端 CreateQuickMatch(…)从未调用CreateQuickMatch(…)中的MatchStart(…)参数。 每次调用CreateQuickMatch(…)时,它都会发送一个错误,“NullReferenceExceptio
// Use this for initialization
void Start ()
{
// recommended for debugging:
PlayGamesPlatform.DebugLogEnabled = true;
// Activate the Google Play Games platform
PlayGamesPlatform.Activate ();
}
void OnMatchStarted (bool success, TurnBasedMatch match)
{
if (success)
{
this.gameMatch = match;
Debug.Log ("Success");
} else
{
Debug.Log ("Failed");
}
}
// Update is called once per frame
void Update ()
{
if (Input.touchCount > 0 && TouchPhase.Ended == Input.GetTouch (0).phase)
{
PlayGamesPlatform.Instance.TurnBased.CreateQuickMatch (minPlayers, maxPlayers, variant, OnMatchStarted);
}
}
我认为在创建房间之前,您需要使用帐户登录。激活Google Play Games平台后,只需添加以下代码
Social.localUser.Authenticate(
(bool success) => { string loginStatus = success ? "Login successful" : "Login failed";
Debug.Log("Login status: " + loginStatus);
});
此功能将打开一个登录屏幕,您可以选择使用哪个帐户登录。函数中的奇怪参数是一个lambda语句,在身份验证过程完成时调用该语句。在这种情况下,函数要么记录“登录状态:登录成功”
要么记录“登录状态:登录失败”