android - What to do when user clicks back on google play games realtime multiplayer auto-match ui? -


i created "play button" starts automatch ui , begins search players.once when ui shows up, when press in automatch ui button ,it returns "play button"....but when press again nothing. works when press quit in automatch ui , press play again

what should doing in code (i'm using google play games unity plugin) when presses button in ui ?

i'm working google play games services unity plugin

i not sure of code looks like, minimal example of creating real-time game. think problem whenever "go back" play button, need call leaveroom() reset multi-player room state.

this based on smoketest sample in gpgs unity plug in project (https://github.com/playgameservices/play-games-plugin-for-unity).

all code (including sample covered under apache 2 license.

using unityengine; using googleplaygames.basicapi.multiplayer; using googleplaygames; using googleplaygames.basicapi;   class samplertmp : monobehaviour, realtimemultiplayerlistener {     bool canstartplaying = true;     bool playinggame = false;      void start()     {         playgamesclientconfiguration config =              new playgamesclientconfiguration.builder()             // registers callback handle game invitations             // received while game not running.         .withinvitationdelegate(oninvitation)         .build();          playgamesplatform.initializeinstance(config);         // recommended debugging:         playgamesplatform.debuglogenabled = true;         // activate google play games platform         playgamesplatform.activate();          // auto login         social.localuser.authenticate((bool success) => {             // handle success or failure         });     }      void ongui()     {          if (playinggame) {             // don't show buttons during game play.             return;                                                                          }                                                                                    if (canstartplaying) {                                                                   if (gui.button(new rect(10, screen.height / 4f, screen.height / 8f, screen.width / 3f), "play")) {                                                                canstartplaying = false;                                                              ulong bitmask = 0l; // no special bitmask players                                uint minopponents = 1; // smallest 2 player game                        uint maxopponents = 1; // largest 2 player game                           playgamesplatform.instance.realtime.createquickgame(minopponents,                           maxopponents, 0, bitmask, this);                                    }                                                                                } else {                                                                                   if (gui.button(new rect(10, screen.height / 4f, screen.height / 12f, 100), "leave room")) {                                                          playgamesplatform.instance.realtime.leaveroom();                 }                                                                                    if (gui.button(new rect(350, screen.height / 4f, screen.height / 12f, 100), "show waiting room")) {                                                   playgamesplatform.instance.realtime.showwaitingroomui();                         }                                                                                }                                                                                }      public void oninvitation(invitation invitation, bool shouldautoaccept)     {         // handle invitation         if (shouldautoaccept) {             playgamesplatform.instance.realtime.acceptinvitation(invitation.invitationid, this);         }         else {             // other stuff.         }     }      // callbacks room setup     public void onroomsetupprogress(float percent)     {                                                                                        // called once initially, each time player joins or leaves.                   // or if waiting room activity returns.                                          debug.log("setting room (" + ((int)percent) + "%)");       }      public void onroomconnected(bool success)     {                                                                                        debug.log("connected room: " + success);                                          if (success) {                                                                           // start playing game!                                                           playinggame = success;                                                           } else {                                                                                   // handle error here,  leave room.                                          playgamesplatform.instance.realtime.leaveroom();                                 }                                                                                }      public void onleftroom()     {                                                                                        debug.log("left room");                                                          canstartplaying = true;                                                          }      public void onparticipantleft(participant participant)     {      }      public void onpeersconnected(string[] participantids)     {      }      public void onpeersdisconnected(string[] participantids)     {         //do stuff     }      public void onrealtimemessagereceived(bool isreliable, string senderid, byte[] data)     {         //do stuff     } } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -