/// <summary>
 /// GUI displayed when the user has not yet authenticated
 /// </summary>
 private void notauthenticatedGUI()
 {
     if (GUILayout.Button("Authenticate"))
     {
         PlayGameServices.authenticate();
     }
 }
예제 #2
0
        private void showAuthAndSetttingsButtons()
        {
            GUILayout.Label("Authentication and Settings");

                        #if UNITY_ANDROID
            if (GUILayout.Button("Authenticate Silently (with no UI)"))
            {
                PlayGameServices.attemptSilentAuthentication();
            }


            if (GUILayout.Button("Get Auth Token"))
            {
                var token = PlayGameServices.getAuthToken(null);
                Debug.Log("token: " + token);
            }
                        #endif


            if (GUILayout.Button("Authenticate"))
            {
                PlayGameServices.authenticate();
            }


            if (GUILayout.Button("Sign Out"))
            {
                PlayGameServices.signOut();
            }


            if (GUILayout.Button("Is Signed In"))
            {
                // Please note that the isSignedIn method is a total hack that was added to work around a current bug where Google
                // does not properly notify an app that the user signed out
                Debug.Log("is signed in? " + PlayGameServices.isSignedIn());
            }


            if (GUILayout.Button("Get Player Info"))
            {
                var playerInfo = PlayGameServices.getLocalPlayerInfo();
                Prime31.Utils.logObject(playerInfo);

                // if we are on Android and have an avatar image available, lets download the profile pic
                if (Application.platform == RuntimePlatform.Android && playerInfo.avatarUri != null)
                {
                    PlayGameServices.loadProfileImageForUri(playerInfo.avatarUri);
                }
            }


            if (GUILayout.Button("Load Remote Player Info"))
            {
                PlayGameServices.loadPlayer("110453866202127902712");
            }
        }
예제 #3
0
        void OnGUI()
        {
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            beginColumn();



            // if there is no game in progress we show buttons to setup a room
            if (!_isGameInProgress)
            {
                if (GUILayout.Button("Authenticate"))
                {
                    PlayGameServices.authenticate();
                }


#if UNITY_IOS
                if (GUILayout.Button("Register Device Token"))
                {
                    if (NotificationServices.deviceToken != null)
                    {
                        GPGMultiplayer.registerDeviceToken(NotificationServices.deviceToken, false);
                    }
                    else
                    {
                        Debug.LogWarning("NotificationServices.deviceToken is null so we are not registering with Google");
                    }
                }
#endif


                GUILayout.Label("Room Creation");

                if (GUILayout.Button("Show Invitation Inbox"))
                {
                    GPGMultiplayer.showInvitationInbox();
                }


                if (GUILayout.Button("Start Quick Match"))
                {
                    GPGMultiplayer.startQuickMatch(1, 1);
                }


                if (GUILayout.Button("Create Room Programmatically"))
                {
                    GPGMultiplayer.createRoomProgrammatically(1, 1);
                }


                if (GUILayout.Button("Show Player Selector"))
                {
                    GPGMultiplayer.showPlayerSelector(1, 1);
                }
            }
            else
            {
                GUILayout.Label("In Real-time Match");

                if (GUILayout.Button("Send Unreliable Message to All"))
                {
                    var bytes = System.Text.Encoding.UTF8.GetBytes("howdy. current time: " + System.DateTime.Now);
                    GPGMultiplayer.sendUnreliableRealtimeMessageToAll(bytes);
                }



                if (GUILayout.Button("Get Room Participants"))
                {
                    var participants = GPGMultiplayer.getParticipants();
                    Utils.logObject(participants);
                }


                if (GUILayout.Button("Leave Room"))
                {
                    GPGMultiplayer.leaveRoom();
                }


                GUILayout.Space(40);

                GUILayout.Label(_lastReceivedMessage);
            }

            endColumn(false);


            if (bottomLeftButton("Back to Standard Demo Scene"))
            {
                Application.LoadLevel("PlayGameServicesDemoScene");
            }
        }