/// <summary> /// 下载失败 /// </summary> void OnFailed(EmErrorCode code) { lock (lock_obj_) { if (content_ != null) { content_.State = DownloadContent.emState.Failed; content_.Close(); content_ = null; } if (http_request_ != null) { http_request_.Abort(); http_request_ = null; } IsDone = true; ErrorCode = code; if (error_callback_ != null) { error_callback_(this); } } }
/// <summary> /// 错误 /// </summary> void Error(EmErrorCode ec, string message = null) { ErrorCode = ec; string ms = string.IsNullOrEmpty(message) ? ErrorCode.ToString() : ErrorCode.ToString() + " - " + message; Debug.LogError(ms); }
/// <summary> /// /// </summary> void Error(EmErrorCode ec, string message = null) { ErrorCode = ec; StringBuilder sb = new StringBuilder("[AssetBundleError] - "); sb.Append(ErrorCode.ToString()); if (!string.IsNullOrEmpty(message)) { sb.Append("\n"); sb.Append(message); } Debug.LogWarning(sb.ToString()); }
/// <summary> /// 开始下载 /// </summary> public void Start(string root, string local_file_name , Action <HttpAsyDownload, long> notify = null , Action <HttpAsyDownload> error_cb = null) { lock (lock_obj_) { Abort(); Root = root; LocalName = local_file_name; IsDone = false; ErrorCode = EmErrorCode.None; notify_callback_ = notify; error_callback_ = error_cb; content_ = new DownloadContent(FullName, false); CompletedLength = 0; Length = 0; _Download(); } }
/// <summary> /// 启动(仅内部启用) /// </summary> void Launch() { if (this._assetbundlePermanent == null) { this._assetbundlePermanent = new Dictionary <string, ZTAssetBundle>(); } if (this._assetbundleTemporary == null) { _assetbundleTemporary = new Dictionary <string, ZTAssetBundle>(); } this.InitTotal = 1; this.InitCurrent = 0; IsReady = false; ErrorCode = EmErrorCode.None; StopAllCoroutines(); StartCoroutine(Preprocess()); }