我正在使用Unity创建一个Android多人游戏,该游戏使用Google Play服务。当我尝试创建房间时:
public void SingInAndStartMPGame(){
if (!PlayGamesPlatform.Instance.localUser.authenticated) {
PlayGamesPlatform.Instance.localUser.Authenticate ((bool success) => {
if (success) {
Debug.Log ("We are singed in, Welcome " + PlayGamesPlatform.Instance.localUser.userName);
StartMatchMaking();
} else {
Debug.Log ("We are not singed in");
}
});
} else {
Debug.Log ("You are already singed in");
StartMatchMaking ();
}
}
private void StartMatchMaking() {
PlayGamesPlatform.Instance.RealTime.CreateQuickGame (minimumOpponents, maximumOpponents, gameVariation, this);
}
我在Logcat中收到以下消息:
08-18 23:31:18.712:I / Unity(12810):您已经被唱歌 08-18 23:31:18.712:I / Unity(12810):
08-18 23:31:18.712:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.712:I / Unity(12810):True 08-18 23:31:18.712:I / Unity(12810):
08-18 23:31:18.712:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.723:I / Unity(12810):[Play Games Plugin DLL] 08/18/18 23:31:18 +03:00调试:激活PlayGamesPlatform。 08-18 23:31:18.723:I / Unity(12810):
08-18 23:31:18.723:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.723:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:18 +03:00调试:PlayGamesPlatform已激活:GooglePlayGames.PlayGamesPlatform 08-18 23:31:18.723:I / Unity(12810):
08-18 23:31:18.723:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.723:I / Unity(12810):[Play Games Plugin DLL] 08/18/18 23:31:18 +03:00调试:激活PlayGamesPlatform。 08-18 23:31:18.723:I / Unity(12810):
08-18 23:31:18.723:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.723:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:18 +03:00调试:PlayGamesPlatform已激活:GooglePlayGames.PlayGamesPlatform 08-18 23:31:18.723:I / Unity(12810):
08-18 23:31:18.723:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.723:I / Unity(12810):[播放游戏插件DLL] 08/18/18 23:31:18 +03:00调试:QuickGame:设置MinPlayersToStart = 2 08-18 23:31:18.723:I / Unity(12810):
08-18 23:31:18.723:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.723:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:18 +03:00调试:OnData回调具有地址:35 08-18 23:31:18.723:I / Unity(12810):
08-18 23:31:18.723:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.723:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:18 +03:00调试:BeforeRoomCreateStartedState.IsNonPreemptable:默认情况下可被抢占。 08-18 23:31:18.723:I / Unity(12810):
08-18 23:31:18.723:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.723:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:18 +03:00调试:进入状态:RoomCreationPendingState 08-18 23:31:18.723:I / Unity(12810):
08-18 23:31:18.723:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:18.723:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:18 +03:00调试:RoomCreationPendingState.OnStateEntered:默认为无操作。 08-18 23:31:18.723:I / Unity(12810):
08-18 23:31:18.723:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:20.812:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:20 +03:00调试:为RealtimeManager#InternalRealTimeRoomCallback输入内部回调 08-18 23:31:20.812:I / Unity(12810):
08-18 23:31:20.812:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:20.812:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:20 +03:00调试:进入状态:ShutdownState 08-18 23:31:20.812:I / Unity(12810):
08-18 23:31:20.812:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:20.812:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:20 +03:00调试:ShutdownState.OnStateEntered:默认为无操作。 08-18 23:31:20.812:I / Unity(12810):
08-18 23:31:20.812:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:20.812:I / Unity(12810):
08-18 23:31:20.812:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:20.812:I / Unity(12810):恩连线到房间时遇到错误! 08-18 23:31:20.812:I / Unity(12810):
08-18 23:31:20.812:I / Unity(12810):(文件名:/Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp行:51) 08-18 23:31:20.829:I / Unity(12810):[玩游戏插件DLL] 08/18/18 23:31:20 +03:00调试:ShutdownState.IsRoomConnected:未连接返回房间。 08-18 23:31:20.829:I / Unity(12810):
08-18 23:31:20.829:I / Unity(12810):(文件名:/ Users / builduser / buildslave / unity / build / artifacts / Generated / common / runtime / DebugBindings.gen.cpp Line:51)
任何帮助将不胜感激。
答案 0 :(得分:0)
使用社交代替 PlayGamesPlatform.Instance
尝试以下代码:
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using GooglePlayGames.BasicApi.Multiplayer;
using UnityEngine.SocialPlatforms;
...
void Start()
{
PlayGamesClientConfiguration Config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(Config);
PlayGamesPlatform.Activate();
}
public void SingInAndStartMPGame()
{
Social.localUser.Authenticate((bool Success) =>
{
if (Success)
{
Debug.Log ("We are singed in, Welcome!");
StartMatchMaking();
}
else
{
Debug.Log ("We are not singed in");
}
});
}
public void StartMatchMaking()
{
PlayGamesPlatform.Instance.RealTime.CreateQuickGame(minimumOpponents, maximumOpponents, gameVariation, this);
}
public void OnRoomConnected(bool success)
{
// Do something after connect
}
public void OnLeftRoom()
{
throw new System.NotImplementedException();
}
public void OnParticipantLeft(Participant participant)
{
throw new System.NotImplementedException();
}
public void OnPeersConnected(string[] participantIds)
{
throw new System.NotImplementedException();
}
public void OnPeersDisconnected(string[] participantIds)
{
throw new System.NotImplementedException();
}
public void OnRealTimeMessageReceived(bool isReliable, string senderId, byte[] data)
{
// Use packets
}
希望这就是您想要的。