Exemple #1
0
 public CdnGet(string contentPath, string saveToFilename, CdnGetFileComplete onGetFileComplete)
 {
     mode                   = ModeEnum.GetFile;
     this.contentPath       = contentPath;
     onGetStringComplete    = null;
     this.saveToFilename    = saveToFilename;
     this.onGetFileComplete = onGetFileComplete;
 }
Exemple #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposed)
     {
         return;
     }
     if (disposing)
     {
         if (webRequestCoroutine != null && !webRequestCoroutine.Disposed)
         {
             webRequestCoroutine.Stop();
             webRequestCoroutine = null;
         }
         if (unityWebRequest != null)
         {
             unityWebRequest.Dispose();
             unityWebRequest = null;
         }
     }
     onGetStringComplete = null;
     onGetFileComplete   = null;
     disposed            = true;
 }
Exemple #3
0
        private IEnumerator getString(string fullAssetUrl)
        {
            unityWebRequest         = UnityWebRequest.Get(fullAssetUrl);
            unityWebRequest.timeout = timeoutSeconds;
            unityWebRequest.disposeDownloadHandlerOnDispose = true;
            yield return(unityWebRequest.SendWebRequest());

            if (unityWebRequest.isNetworkError || unityWebRequest.isHttpError)
            {
                Log.LogErrorFormatted(this, "Error: getString({0}):\n{1}", fullAssetUrl, unityWebRequest.error);
                if (onGetStringComplete != null)
                {
                    onGetStringComplete(success: false, null, unityWebRequest.error);
                }
            }
            else if (onGetStringComplete != null)
            {
                onGetStringComplete(success: true, unityWebRequest.downloadHandler.text, null);
            }
            onGetStringComplete = null;
            unityWebRequest.Dispose();
            unityWebRequest = null;
        }