//============================================================================= public void Logout() { #if UNITY_IPHONE if ((IsLoggedIn() == true) && (m_ManagerState == eManagerState.Idle)) { // Stop auto log-in from now on PlayerPrefs.SetInt("GCGPAutoLogin", 0); m_bIsLoggedIn = false; m_ManagerState = eManagerState.Idle; if (LogoutSuccessEvent != null) { LogoutSuccessEvent(); } } #endif #if UNITY_ANDROID if ((IsLoggedIn() == true) && (m_ManagerState == eManagerState.Idle)) { // Stop auto log-in from now on PlayerPrefs.SetInt("GCGPAutoLogin", 0); m_bIsLoggedIn = false; m_ManagerState = eManagerState.Idle; PlayGameServices.signOut(); if (LogoutSuccessEvent != null) { LogoutSuccessEvent(); } } #endif }
public void ToggleSignIn() { if (IsSignedIn) { PlayGameServices.signOut(); } else { 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); }