Google Play Games Realtime multiplayer: Getting participant Id and storing it to a string

我只是一个虾纸丫 提交于 2019-12-30 06:50:06

问题


I am trying google realtime multiplayer for the very 1st time in my unity game. QuickMatch is working just fine, I mean I am able to get the connected participant's ID and store it to a string using:

string MyId = PlayGamesPlatform.Instance.RealTime.GetSelf ().ParticipantId;

//string frndId = PlayGamesPlatform.Instance.RealTime.GetParticipant ();
//Get all opponent's ID
List<Participant> playerIDs = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants ();

if (MyId == playerIDs [0].ParticipantId) {

    oppoUsarname = playerIDs [1].DisplayName.ToString ();
    multiplayersName [1].text = "nothosting" + oppoUsarname;
    gameHost = true;

    OppoID = playerIDs [1].ParticipantId;

    OppoDN = playerIDs [1].DisplayName.ToString ();
} else {
    oppoUsarname = playerIDs [0].DisplayName.ToString ();
    multiplayersName [1].text = "gamehoster" + oppoUsarname;
    gameHost = false;
     OppoID = playerIDs [0].ParticipantId;
     OppoDN = playerIDs [0].DisplayName.ToString ();
}

just after an opponent connect to the room I can show his displayname. But for CreateWithInvitationScreen I want to get the invited (whom I have invited using invitation screen) participant's ID even when they have not accepted the invitation or connected to the room... can anyone tell me how to do it?

来源:https://stackoverflow.com/questions/52739109/google-play-games-realtime-multiplayer-getting-participant-id-and-storing-it-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!