/// <summary>
        /// Initializes Apple Game Center.
        /// </summary>
        /// <param name="activateCloudSave">Whether or not Cloud Saving should be activated.</param>
        /// <param name="autoSignIn">
        /// Whether or not <see cref="SignIn"/> will be called automatically once the cloud provider is initialized.
        /// Ignored on Amazon GameCircle as there is no way of avoiding auto sign in.
        /// </param>
        /// <param name="autoCloudLoad">
        /// Whether or not cloud data should be loaded automatically if the user is successfully signed in.
        /// Ignored if Cloud Saving is deactivated.
        /// </param>
        public override void Initialize(bool activateCloudSave = true, bool autoSignIn = true, bool autoCloudLoad = true)
        {
            // Ignore repeated calls on Initialize
            if (isInitializing)
            {
                return;
            }
#if CLOUDONCE_DEBUG
            Debug.Log("Initializing Apple Game Center.");
#endif
            isInitializing   = true;
            cloudSaveEnabled = activateCloudSave;
#if CLOUDONCE_DEBUG
            Debug.Log(cloudSaveEnabled ? "iCloud support enabled." : "iCloud support disabled.");
#endif
            if (autoSignIn)
            {
                var onSignedIn = new UnityAction <bool>(arg0 =>
                {
                    cloudOnceEvents.RaiseOnInitializeComplete();
                    isInitializing = false;
                });
                SignIn(autoCloudLoad, onSignedIn);
                return;
            }

            if (cloudSaveEnabled && autoCloudLoad)
            {
                var iCloudWrapper = (iOSCloudSaveWrapper)Storage;
                iCloudWrapper.Load();
            }

            cloudOnceEvents.RaiseOnInitializeComplete();
            isInitializing = false;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes Google Play Game Services.
        /// </summary>
        /// <param name="activateCloudSave">Whether or not Cloud Saving should be activated.</param>
        /// <param name="autoSignIn">
        /// Whether or not <see cref="SignIn"/> will be called automatically once Google Play Game Services is initialized.
        /// </param>
        /// <param name="autoCloudLoad">
        /// Whether or not cloud data should be loaded automatically if the user is successfully signed in.
        /// Ignored if Cloud Saving is deactivated or the user fails to sign in.
        /// </param>
        public override void Initialize(bool activateCloudSave = true, bool autoSignIn = true, bool autoCloudLoad = true)
        {
            if (initializing)
            {
                return;
            }
#if CLOUDONCE_DEBUG
            Debug.Log("Initializing Google Play Game Services.");
#endif
            initializing = true;

            cloudSaveEnabled = activateCloudSave;

#if CLOUDONCE_DEBUG
            Debug.Log("Saved Games support " + (activateCloudSave ? "enabled." : "disabled."));
#endif
            var config = new PlayGamesClientConfiguration.Builder();
            if (activateCloudSave)
            {
                config.EnableSavedGames();
                CloudSaveInitialized = true;
            }

            PlayGamesPlatform.InitializeInstance(config.Build());

            SubscribeOnAuthenticatedEvent();

#if CLOUDONCE_DEBUG   // Enable/disable logs on the PlayGamesPlatform
            PlayGamesPlatform.DebugLogEnabled = true;
            Debug.Log("PlayGamesPlatform debug logs enabled.");
#else
            PlayGamesPlatform.DebugLogEnabled = false;
            Debug.Log("PlayGamesPlatform debug logs disabled.");
#endif
            IsGpgsInitialized = true;
            if (!IsGuestUserDefault && autoSignIn)
            {
                var onSignedIn = new UnityAction <bool>(arg0 =>
                {
                    cloudOnceEvents.RaiseOnInitializeComplete();
                    initializing = false;
                });
                SignIn(autoCloudLoad, onSignedIn);
            }
            else
            {
                if (IsGuestUserDefault && autoSignIn)
                {
                    Logger.d("Guest user mode active, ignoring auto sign-in. Please call SignIn directly.");
                }

                if (autoCloudLoad)
                {
                    cloudOnceEvents.RaiseOnCloudLoadComplete(false);
                }

                cloudOnceEvents.RaiseOnInitializeComplete();
                initializing = false;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Dummy Initialize method.
 /// </summary>
 /// <param name="activateCloudSave">Whether or not Cloud Saving should be activated.</param>
 /// <param name="autoSignIn">
 /// Whether or not <see cref="SignIn"/> will be called automatically once the cloud provider is initialized.
 /// </param>
 /// <param name="autoCloudLoad">
 /// Whether or not cloud data should be loaded automatically if the user is successfully signed in.
 /// Ignored if Cloud Saving is deactivated or the user fails to sign in.
 /// </param>
 public override void Initialize(bool activateCloudSave = true, bool autoSignIn = true, bool autoCloudLoad = true)
 {
     cloudOnceEvents.RaiseOnInitializeComplete();
     cloudOnceEvents.RaiseOnPlayerImageDownloaded(Texture2D.whiteTexture);
     if (autoSignIn)
     {
         SignIn(autoCloudLoad);
     }
 }
        private void ServiceReadyEvent()
        {
#if CLOUDONCE_DEBUG
            Debug.Log("OnServiceReady");
#endif
            if (cloudSaveEnabled)
            {
                // Due to some flaws in the Amazon SDK lib (static constructors,
                // where one depends on another being called first, AGSClient.Init must be called before
                // AGSWhispersyncClient) we put the initialization logic here.
                // Otherwise we will not get some of the event callbacks we need.
#if CLOUDONCE_DEBUG
                Debug.Log("Initializing WhisperSync");
#endif
                AGSWhispersyncClient.InitAGSWhispersyncClient();
                CloudSaveInitialized = true;
            }

            cloudOnceEvents.RaiseOnInitializeComplete();
            AGSClient.ServiceReadyEvent -= ServiceReadyEvent;
            isInitializing = false;
        }