/// <summary> /// Signs in to Apple Game Center. /// </summary> /// <param name="autoCloudLoad"> /// Whether or not cloud data should be loaded automatically when the user is successfully signed in. /// Ignored if Cloud Saving is deactivated or the user fails to sign in. /// </param> /// <param name='callback'> /// The callback to call when authentication finishes. It will be called /// with <c>true</c> if authentication was successful, <c>false</c> otherwise. /// </param> public override void SignIn(bool autoCloudLoad = true, UnityAction <bool> callback = null) { if (isSigningIn) { return; } isSigningIn = true; if (IsSignedIn) { #if CLOUDONCE_DEBUG Debug.Log("Already signed in to Apple Game Center." + " If you want to change the user, that must be done from the iOS Settings menu."); #endif CloudOnceUtils.SafeInvoke(callback, true); if (CloudSaveEnabled && autoCloudLoad) { var iCloudWrapper = (iOSCloudSaveWrapper)Storage; iCloudWrapper.Load(); } isSigningIn = false; return; } Social.localUser.Authenticate( success => { if (success) { #if CLOUDONCE_DEBUG Debug.Log("Successfully signed in to Apple Game Center."); #endif cloudOnceEvents.RaiseOnSignedInChanged(true); cloudOnceEvents.RaiseOnPlayerImageDownloaded(Social.localUser.image); UpdateAchievementsData(); } else { #if CLOUDONCE_DEBUG Debug.LogWarning("Failed to sign in to Apple Game Center."); #endif cloudOnceEvents.RaiseOnSignInFailed(); } if (CloudSaveEnabled && autoCloudLoad) { var iCloudWrapper = (iOSCloudSaveWrapper)Storage; iCloudWrapper.Load(); } CloudOnceUtils.SafeInvoke(callback, success); isSigningIn = false; }); }
private void OnSignedInStateChangedEvent(bool signedIn) { if (signedIn) { #if CLOUDONCE_DEBUG Debug.Log("Signed in to Amazon GameCircle."); #endif if (CloudSaveInitialized && cloudSaveEnabled && autoLoadOnSignInEnabled) { Cloud.Storage.Load(); } AGSPlayerClient.RequestLocalPlayer(); UpdateAchievementsData(); } else { #if CLOUDONCE_DEBUG Debug.Log("Signed out of Amazon GameCircle."); #endif } cloudOnceEvents.RaiseOnSignedInChanged(signedIn); }
/// <summary> /// Sets <see cref="IsGuestUserDefault"/> to <c>true</c> and raises the <see cref="CloudOnceEvents.OnSignedInChanged"/> event. /// </summary> public void ActivateGuestUserMode() { IsGuestUserDefault = true; cloudOnceEvents.RaiseOnSignedInChanged(false); }