快速匹配等候室弹出一次,然后在 Unity 中使用 Google 玩游戏离开

Posted

技术标签:

【中文标题】快速匹配等候室弹出一次,然后在 Unity 中使用 Google 玩游戏离开【英文标题】:Quick Match waiting room pops one time and leave with Google play games in Unity 【发布时间】:2018-01-12 17:57:46 【问题描述】:

我在统一使用 Google Play 游戏插件时有一个奇怪的行为。

在我添加代码以发送和接收实时消息后,游戏前等候室的 UI 弹出一次,离开,什么也没有发生(通常我会匹配其他玩家,游戏在第二台设备上运行)。

在我添加代码之前,一切正常(屏幕一直停留直到找到对手,游戏开始)。

不知道为什么会出现这个问题。

这是我点击获取快速匹配(随机匹配)时的日志:

I/Unity ( 6389): UnityEngine.Logger:Log(LogType, Object)
I/Unity ( 6389): UnityEngine.Debug:Log(Object)
I/Unity ( 6389): GooglePlayGames.OurUtils.c__AnonStorey15:<>m__D() (at E:\A
pplication\R Hockey\Assets\GooglePlayGames\OurUtils\Logger.cs:59)
I/Unity ( 6389): GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() (at E
:\Application\R Hockey\Assets\GooglePlayGames\OurUtils\PlayGamesHelperObject.cs:
135)
I/Unity ( 6389):
I/Unity ( 6389): (Filename: E Line: 0)
I/Unity ( 6389):
I/Unity ( 6389): [Play Games Plugin DLL] 08/01/17 13:19:21 +02:00 DEBUG: Not
leaving room since showing UI
I/Unity ( 6389): UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Obj
ect)
I/Unity ( 6389): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String
, Object[])
I/Unity ( 6389): UnityEngine.Logger:Log(LogType, Object)
I/Unity ( 6389): UnityEngine.Debug:Log(Object)
I/Unity ( 6389): GooglePlayGames.OurUtils.c__AnonStorey15:<>m__D() (at E:\A
pplication\R Hockey\Assets\GooglePlayGames\OurUtils\Logger.cs:59)
I/Unity ( 6389): GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() (at E
:\Application\R Hockey\Assets\GooglePlayGames\OurUtils\PlayGamesHelperObject.cs:
135)
I/Unity ( 6389):
I/Unity ( 6389): (Filename: E Line: 0)
I/Unity ( 6389):
I/Unity ( 6389): [Play Games Plugin DLL] 08/01/17 13:19:21 +02:00 DEBUG: Ente
ring internal callback for RealtimeManager#InternalWaitingRoomUICallback
I/Unity ( 6389): UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Obj
ect)
I/Unity ( 6389): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String
, Object[])
I/Unity ( 6389): UnityEngine.Logger:Log(LogType, Object)
I/Unity ( 6389): UnityEngine.Debug:Log(Object)
I/Unity ( 6389): GooglePlayGames.OurUtils.c__AnonStorey15:<>m__D() (at E:\A
pplication\R Hockey\Assets\GooglePlayGames\OurUtils\Logger.cs:59)
I/Unity ( 6389): GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() (at E
:\Application\R Hockey\Assets\GooglePlayGames\OurUtils\PlayGamesHelperObject.cs:
135)
I/Unity ( 6389):
I/Unity ( 6389): (Filename: E Line: 0)
I/Unity ( 6389):
I/Unity ( 6389): [Play Games Plugin DLL] 08/01/17 13:19:21 +02:00 DEBUG: Show
WaitingRoomUI Response: VALID
I/Unity ( 6389): UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Obj
ect)
I/Unity ( 6389): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String
, Object[])
I/Unity ( 6389): UnityEngine.Logger:Log(LogType, Object)
I/Unity ( 6389): UnityEngine.Debug:Log(Object)
I/Unity ( 6389): GooglePlayGames.OurUtils.c__AnonStorey15:<>m__D() (at E:\A
pplication\R Hockey\Assets\GooglePlayGames\OurUtils\Logger.cs:59)
I/Unity ( 6389): GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() (at E
:\Application\R Hockey\Assets\GooglePlayGames\OurUtils\PlayGamesHelperObject.cs:
135)
I/Unity ( 6389):
I/Unity ( 6389): (Filename: E Line: 0)
I/Unity ( 6389):
I/Unity ( 6389): [Play Games Plugin DLL] 08/01/17 13:19:21 +02:00 DEBUG: Conn
ecting state ShowWaitingRoomUI: room pcount:1 status: AUTO_MATCHING
I/Unity ( 6389): UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Obj
ect)
I/Unity ( 6389): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String
, Object[])
I/Unity ( 6389): UnityEngine.Logger:Log(LogType, Object)
I/Unity ( 6389): UnityEngine.Debug:Log(Object)
I/Unity ( 6389): GooglePlayGames.OurUtils.c__AnonStorey15:<>m__D() (at E:\A
pplication\R Hockey\Assets\GooglePlayGames\OurUtils\Logger.cs:59)
I/Unity ( 6389): GooglePlayGames.OurUtils.PlayGamesHelperObject:Update() (at E
:\Application\R Hockey\Assets\GooglePlayGames\OurUtils\PlayGamesHelperObject.cs:
135)
I/Unity ( 6389):
I/Unity ( 6389): (Filename: E Line: 0)
I/Unity ( 6389):
D/dalvikvm( 3322): GC_CONCURRENT freed 3216K, 31% free 17725K/25376K, paused 6ms
+7ms, total 95ms
W/ActivityManager( 2461): `mDVFSHelper.release()

我发现当我使用此行向其他玩家发送消息时出现问题:

PlayGamesPlatform.Instance.RealTime.SendMessageToAll (false, bytedata);

为什么这条线会导致 UI 弹出?

(当我没有这条线时,一切都恢复正常。但这条线是发送消息的唯一原因,根据github)。

【问题讨论】:

【参考方案1】:

不知道您的代码是什么样的,您可能需要检查以下内容:

Configuration and initialization of Play Game Services。 你应该如何launch the waiting room UI的步骤 请注意,您应该只在您的应用程序中调用一次PlayGamesPlatform.Activate。进行此调用不会在屏幕上显示任何内容,也不会以任何方式与用户交互。

最后,用于解决this post 中的错误的解决方法也可能会有所帮助。请勿拨打PlayGamesPlatform.Instance.RealTime.ShowWaitingRoomUI();OnRoomSetupProgress(float percent).

【讨论】:

感谢您的回复。在OnRoomSetupProgress(float percent) 中不调用ShowWaitingRoomUI() 很奇怪,因为在github 中,他们是这样编码的。但是我怎样才能在 Unity 和 c# 中获得Intent i = Games.RealTimeMultiplayer.getWaitingRoomIntent

以上是关于快速匹配等候室弹出一次,然后在 Unity 中使用 Google 玩游戏离开的主要内容,如果未能解决你的问题,请参考以下文章

利用cookie实现“只弹出一次窗口”的JS代码

Element 通知组件 Notification 支持同类型的提示信息只弹出一次!!!

js实现弹出的提示框只弹出一次

JavaScript 弹出一次

javascript只弹出一次框 再次刷新不弹出

bootstrap 模态框 每天自动弹出一次怎么实现