public CdnGet(string contentPath, string saveToFilename, CdnGetFileComplete onGetFileComplete) { mode = ModeEnum.GetFile; this.contentPath = contentPath; onGetStringComplete = null; this.saveToFilename = saveToFilename; this.onGetFileComplete = onGetFileComplete; }
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; }
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; }