android - Unity - Google Play 游戏服务实时多人游戏关闭 WaitingRoomUI() 方法?

标签 android unity-game-engine google-play-games

有没有在 WaitingRoomUI 关闭时执行的方法?

非常感谢任何帮助,谢谢。

最佳答案

因为正在使用 startActivityForResult 启动等候室。您需要在启动等候室的 Activity 的 onActivityResult() 方法中捕获结果。

@Override
public void onActivityResult(int request, int response, Intent intent)     {
    if (request == RC_WAITING_ROOM) {
        if (response == Activity.RESULT_OK) {
            // (start game)
        }
        else if (response == Activity.RESULT_CANCELED) {
        // Waiting room was dismissed with the back button. The meaning of this
        // action is up to the game. You may choose to leave the room and cancel the
        // match, or do something else like minimize the waiting room and
        // continue to connect in the background.

        // in this example, we take the simple approach and just leave the room:
        Games.RealTimeMultiplayer.leave(mGoogleApiClient, null, mRoomId);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
    else if (response == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
        // player wants to leave the room.
        Games.RealTimeMultiplayer.leave(mGoogleApiClient, null, mRoomId);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}

您可以在下面的链接中阅读完整的实现。 https://developers.google.com/games/services/android/realtimeMultiplayer

关于android - Unity - Google Play 游戏服务实时多人游戏关闭 WaitingRoomUI() 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34481325/

相关文章:

android - Google Play 服务多人游戏参与者的身份

android - 添加 BaseGamesUtils 导致 gradle 不同步

安卓 : Insert multiple rows into sqlite database not working

unity-game-engine - Vuforia DigitalEyewearBehaviour 设置在运行时更改不起作用

ios - Unity IOS 集成

unity-game-engine - unity 为移动物体烘焙光

java - 将 google play services 版本添加到应用程序的 list 中会出错

android - Android 上的 Pocketsphinx 无法找到声学模型定义 mdef

android - 强制在 BottomNavigationView 中显示图标和标题支持 android

android - Activity 生命周期 - 声明顺序的重要性