public static void TryAuthentication(bool forceMode = false) { if (instanceExists && instance.debugMode) { Debug.LogFormat("PlayGameCenterManager:TryAuthentication({0}) - isAuthenticated={1}, isLastAuthenticationFailed={2}", forceMode, isAuthenticated, isLastAuthenticationFailed); } if (IsSingedIn()) // If already logined, skip here { return; } if (isLastAuthenticationFailed && !forceMode) // If last login failed, don't do it again (unless in forceMode) { return; } _isForcingAuthentication = forceMode; #if UNITY_IOS GameCenterBinding.authenticateLocalPlayer(forceMode); // Authenticate the player #elif UNITY_ANDROID && !CHS if (forceMode) { PlayGameServices.authenticate(); // Authenticate with UI } else { PlayGameServices.attemptSilentAuthentication(); // Authenticate Silently (with no UI) } #endif }
public void StartLeaderboard(bool autoStart = false) { if (!Network.IsInternetConnection() && !autoStart) { Core.Utility.Popup.PopupMessages.Me.InternetConnectionMessgae(); return; } #if UNITY_IOS && GAMECENTER if (!GameCenterBinding.isPlayerAuthenticated()) { GameCenterBinding.authenticateLocalPlayer(); } #endif #if UNITY_ANDROID #if GPGSERVIES && !AMAZONSTORE GPGManager.authenticationFailedEvent += (string error) => { MyDebug.Log("Prime[31] Google Play service authenticate fail with error:\n" + error); }; GPGManager.authenticationSucceededEvent += (string data) => { MyDebug.Log("Prime[31] Google Play service authenticate compelete with data:\n" + data); }; if (!PlayGameServices.isSignedIn()) { #if MYDEBUG PlayGameServices.enableDebugLog(true); #endif PlayGameServices.authenticate(); } #endif #endif }
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(); } GUILayout.Label("Room Creation"); if (GUILayout.Button("Show Invitation Inbox")) { GPGMultiplayer.showInvitationInbox(); } if (GUILayout.Button("Create Room Programmatically")) { GPGMultiplayer.createRoomProgrammatically(1, 1, 0); } if (GUILayout.Button("Show Player Selector")) { GPGMultiplayer.showPlayerSelector(1, 1); } } else { GUILayout.Label("In Real-time Match"); if (GUILayout.Button("Leave Room")) { GPGMultiplayer.leaveRoom(); } if (GUILayout.Button("Send Unreliable Message to All")) { var bytes = System.Text.Encoding.UTF8.GetBytes("howdy. current time: " + System.DateTime.Now); GPGMultiplayer.sendUnreliableRealtimeMessageToAll(bytes); } GUILayout.Space(40); GUILayout.Label(_lastReceivedMessage); } endColumn(false); }
public void Authenticate() { #if UNITY_IPHONE || UNITY_ANDROID Init(); PlayGameServices.setAchievementToastSettings(GPGToastPlacement.Center, 50); PlayGameServices.authenticate(); Debug.LogWarning("MySocial authenticate"); #endif }
public void Login() { #if UNITY_ANDROID if (!PlayGameServices.isSignedIn()) { ZedLogger.Log("trying to authenticate local player"); PlayGameServices.authenticate(); } #endif }
public void StartGoogleCloudLogin() { Debug.Log("StartGoogleCloudLogin() called"); if (!PlayGameServices.isSignedIn() && !googleCloudTryingToLogin) { Debug.Log("StartGoogleCloudLogin() authenticate called"); PlayGameServices.authenticate(); googleCloudTryingToLogin = true; } }
public void ShowLeaderboard() { if (IsSignedIn) { PlayGameServices.showLeaderboards(); } else { PlayGameServices.authenticate(); } }
public void ShowAchievements() { if (IsSignedIn) { PlayGameServices.showAchievements(); } else { PlayGameServices.authenticate(); } }
public void ToggleSignIn() { if (IsSignedIn) { PlayGameServices.signOut(); } else { PlayGameServices.authenticate(); } }
// Use this for initialization void Start() { #if UNITY_ANDROID PlayGameServices.enableDebugLog(true); // we always want to call init as soon as possible after launch. Be sure to pass your own clientId to init on iOS! // This call is not required on Android. //PlayGameServices.init( "YOUR_CLIENT_ID", true ); PlayGameServices.init("366869334068.apps.googleusercontent.com", true); PlayGameServices.authenticate(); #endif }
public void Show() { #if UNITY_ANDROID Debug.Log("Try to show leaderboard."); if (PlayGameServices.isSignedIn()) { Debug.Log("SignedIn. ShowLeaderboard."); PlayGameServices.showLeaderboard(_leaderboardId); } else { Debug.Log("Not SidngedIn. Authenticate."); PlayGameServices.authenticate(); } #else Debug.Log("Error. AndroidLeaderboard.Show call for not android platform."); #endif }
public AndroidLeaderboard(string leaderboardId) { #if UNITY_ANDROID Debug.Log("Init android leaderboard."); _leaderboardId = leaderboardId; PlayGameServices.enableDebugLog(true); GPGManager.authenticationFailedEvent += GPGManager_authenticationFailedEvent; GPGManager.authenticationSucceededEvent += GPGManager_authenticationSucceededEvent; GPGManager.submitScoreFailedEvent += GPGManager_submitScoreFailedEvent; GPGManager.submitScoreSucceededEvent += GPGManager_submitScoreSucceededEvent; Debug.Log("Try silent authentication."); //PlayGameServices.attemptSilentAuthentication(); PlayGameServices.authenticate(); #else Debug.Log("Error. AndroidLeaderboard call for not android platform."); #endif }
//============================================================================= public void Login() { #if UNITY_IPHONE if ((IsLoggedIn() == false) && (m_ManagerState == eManagerState.Idle)) { GameCenterBinding.authenticateLocalPlayer(); m_ManagerState = eManagerState.Login; } else { if (LoginFailEvent != null) { LoginFailEvent("Error - Already logged in or manager busy"); } } #endif #if UNITY_ANDROID if ((IsLoggedIn() == false) && (m_ManagerState == eManagerState.Idle)) { if (PlayerPrefs.GetInt("GCGPAutoLogin", 0) > 0) { PlayGameServices.attemptSilentAuthentication(); } else { PlayGameServices.authenticate(); } m_ManagerState = eManagerState.Login; } else { if (LoginFailEvent != null) { LoginFailEvent("Error - Already logged in or manager busy"); } } #endif }
void Start() { PlayGameServices.authenticate(); }
public void InitCall() { //if(!PlayGameServices.isSignedIn()) PlayGameServices.authenticate(); }
void OnGUI() { GUI.skin.label.alignment = TextAnchor.MiddleCenter; beginColumn(); GUILayout.Label("Authentication and Settings"); if (GUILayout.Button("Set Toasts on Bottom")) { PlayGameServices.setAchievementToastSettings(GPGToastPlacement.Bottom, 50); } 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(); Debug.Log(playerInfo); // if we are on Android and have an avatar image available, lets download the profile pic if (Application.platform == RuntimePlatform.Android && playerInfo.avatarUrl != null) { PlayGameServices.loadProfileImageForUri(playerInfo.avatarUrl); } } GUILayout.Label("Achievements"); if (GUILayout.Button("Show Achievements")) { PlayGameServices.showAchievements(); } if (GUILayout.Button("Increment Achievement")) { PlayGameServices.incrementAchievement("CgkI_-mLmdQEEAIQAQ", 2); } if (GUILayout.Button("Unlock Achievment")) { PlayGameServices.unlockAchievement("CgkI_-mLmdQEEAIQAw"); } endColumn(true); // toggle to show two different sets of buttons if (toggleButtonState("Show Cloud Save Buttons")) { secondColumnButtions(); } else { cloudSaveButtons(); } toggleButton("Show Cloud Save Buttons", "Toggle Buttons"); endColumn(false); }