Beispiel #1
0
        private IEnumerator DownloadPlayerImage(string url)
        {
#if UNITY_2017_2_OR_NEWER
            using (var request = UnityWebRequestTexture.GetTexture(url))
            {
                yield return(request.SendWebRequest());

#if UNITY_2020_1_OR_NEWER
                if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
#else
                if (request.isNetworkError || request.isHttpError)
#endif
                {
                    yield break;
                }

                playerImage = DownloadHandlerTexture.GetContent(request);
            }
#else
            var www = new WWW(url);
            yield return(www);

            playerImage = www.texture;
#endif
            cloudOnceEvents.RaiseOnPlayerImageDownloaded(playerImage);
        }
Beispiel #2
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);
     }
 }
        /// <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 IEnumerator DownloadPlayerImage(string url)
        {
            // Start a download of the given URL
            var www = new WWW(url);

            // Wait for download to complete
            yield return(www);

            // assign texture
            playerImage = www.texture;
            cloudOnceEvents.RaiseOnPlayerImageDownloaded(playerImage);
        }