Google Play服务产生回合制多人比赛问题
本文关键字:问题 服务 Play Google | 更新日期: 2023-09-27 18:10:09
Issue
我有问题与创建一个回合制多人比赛使用google play services在unity3D。
- PlayGamesPlatform. activate()成功初始化PlayGamesPlatform。然而,它没有初始化IPlayGamesClient或ITurnBasedMultiplayerClient。
- CreateQuickMatch(…)不调用OnMatchStarted(…),参数在CreateQuickMatch(…)。
- 每次CreateQuickMatch(…)被调用时,它发送一个错误, "NullReferenceException:对象引用未设置为对象的实例googleplaygames . playgames平台. get_turnbased ()"
已采取的步骤
-
我已经在网上研究了这个问题。某些论坛已经注意到,这个问题是由于GooglePlay API最近的变化。解决方案是将API降级到先前的版本。不成功
-
更新 java和java JDK结果不成功。
作为参考的链接
https://github.com/playgameservices/play-games-plugin-for-unityhttps://github.com/playgameservices/play-games-plugin-for-unity/blob/master/TBMP.md
// 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游戏平台后添加以下代码:
Social.localUser.Authenticate(
(bool success) => { string loginStatus = success ? "Login successful" : "Login failed";
Debug.Log("Login status: " + loginStatus);
});
此功能将打开一个登录屏幕,您可以选择使用哪个帐户登录。函数中奇怪的参数是一个lambda语句,它在身份验证过程完成时被调用。在本例中,该函数记录"Login status: Login successful"
或"Login status: Login failed"
。