【问题标题】:Google Play Services real time multiplayer room creation doesn't workGoogle Play 服务实时多人房间创建不起作用
【发布时间】:2019-01-25 12:12:32
【问题描述】:

我正在使用 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): 真 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):[Play Games Plugin 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):[Play Games Plugin 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 调试: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):[Play Games Plugin 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):[Play Games Plugin 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): [Play Games Plugin 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):[Play Games Plugin 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): [Play Games Plugin 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): [Play Games Plugin 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):[Play Games Plugin DLL] 2018 年 8 月 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): [Play Games Plugin 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 行:51)

任何帮助将不胜感激。

【问题讨论】:

    标签: android unity3d service multiplayer playback


    【解决方案1】:

    使用 Social 代替 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
    }
    

    希望这是你想要的。

    【讨论】:

    • 不。问题在于房间的创建。用户已通过身份验证
    • 如果您的项目“准备好测试”,您是否添加辅助帐户进行测试?指纹 SHA1 是否正确上传?多人游戏是否正确设置为开启?
    • 是的,所有这些事情都正确地完成了。另外,我可以得到谷歌用户名等。所以必须正确设置谷歌播放服务。
    猜你喜欢
    • 2013-11-13
    • 1970-01-01
    • 2014-12-09
    • 2013-06-21
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    • 1970-01-01
    • 2016-06-24
    相关资源
    最近更新 更多