Google Play Games Realtime multiplayer: Getting pa

2020-03-03 07:00发布

问题:

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?