public void BeginLoad(CRequest req) { this.isFree = false; this._req = req; this.enabled = true; string url = CUtils.CheckWWWUrl(req.url); if (req.head is WWWForm) { // Debug.Log ("request" + req.head); www = new WWW(url, (WWWForm)req.head); } else if (req.head is byte[]) { www = new WWW(url, (byte[])req.head); } else { // if (url.StartsWith ("http")) { // if(CResLoader.assetBundleManifest!=null) // www = WWW.LoadFromCacheOrDownload (url, CResLoader.assetBundleManifest.GetAssetBundleHash (req.assetBundleName), 0); // else // www = WWW.LoadFromCacheOrDownload (url, 0); // } // else www = new WWW(url); } #if HUGULA_LOADER_DEBUG Debug.LogFormat(" 0. <color=#8cacbc> begin load : url({0}),key:({1}) assetName({2}) abName({3}) )</color>", req.url, req.key, req.assetName, req.assetBundleName); #endif }
void m_Start() { var type = cRequest.assetType; var userData = cRequest.uploadData; string url = CUtils.CheckWWWUrl(cRequest.url); Dictionary <string, string> wwwheaders = null; var headers = cRequest.webHeader; if (headers != null) { wwwheaders = new Dictionary <string, string> (); foreach (var k in headers.AllKeys) { wwwheaders[k] = headers.Get(k); } } if (userData is WWWForm) { var wwwform = (WWWForm)userData; if (wwwheaders != null && wwwheaders.ContainsKey("host")) { wwwform.headers["host"] = wwwheaders["host"]; m_webrequest = new WWW(url, wwwform.data, wwwform.headers); } else { m_webrequest = new WWW(url, (WWWForm)userData); } } else if (userData is string) { var bytes = LuaHelper.GetBytes(userData.ToString()); if (wwwheaders != null) { m_webrequest = new WWW(url, bytes, wwwheaders); } else { m_webrequest = new WWW(url, bytes); } } else if (userData is System.Array) { if (wwwheaders != null) { m_webrequest = new WWW(url, (byte[])userData, wwwheaders); } else { m_webrequest = new WWW(url, (byte[])userData); } } else { m_webrequest = new WWW(url); } }
private void _BeginDownload() { m_Data = null; Dictionary <string, string> headers = null; if (cRequest.head != null) { headers = new Dictionary <string, string>(); foreach (var k in cRequest.head.AllKeys) { headers[k] = cRequest.head.Get(k); } } var userdata = cRequest.userData; string url = CUtils.CheckWWWUrl(cRequest.url); if (userdata is WWWForm) { m_webrequest = new WWW(url, (WWWForm)userdata); } else if (userdata is string) { var bytes = LuaHelper.GetBytes(userdata.ToString()); if (headers != null) { m_webrequest = new WWW(url, (byte[])userdata, headers); } else { m_webrequest = new WWW(url, bytes); } } else if (userdata is System.Array) { if (headers != null) { m_webrequest = new WWW(url, (byte[])userdata, headers); } else { m_webrequest = new WWW(url, (byte[])userdata); } } else { m_webrequest = new WWW(url); } }
/// <summary> /// lua bundle /// </summary> /// <returns></returns> private IEnumerator DecryptLuaBundle(string luaPath, bool isStreaming, LuaFunction onLoadedFn) { luaPath = CUtils.CheckWWWUrl(luaPath); Debug.Log("loadluabundle:" + luaPath); WWW luaLoader = new WWW(luaPath); yield return(luaLoader); if (luaLoader.error == null) { byte[] byts = CryptographHelper.Decrypt(luaLoader.bytes, DESHelper.instance.Key, DESHelper.instance.IV); AssetBundleCreateRequest abcreq = null; #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 abcreq = AssetBundle.CreateFromMemory(byts); #else abcreq = AssetBundle.LoadFromMemoryAsync(byts); #endif yield return(abcreq); var item = abcreq.assetBundle; TextAsset[] all = item.LoadAllAssets <TextAsset>(); foreach (var ass in all) { SetRequire(ass.name, ass); } item.Unload(false); luaLoader.Dispose(); } else { Debug.LogWarning(luaLoader.error); } if (onLoadedFn != null) { onLoadedFn.call(); } else { DoMain(); } }
private void _BeginDownload() { m_Data = null; var head = cRequest.head; string url = CUtils.CheckWWWUrl(cRequest.url); bool isOverrideHost = string.IsNullOrEmpty(cRequest.overrideHost); if (head is WWWForm) { m_webrequest = new WWW(url, (WWWForm)head); } else if (head is string) { var bytes = LuaHelper.GetBytes(head.ToString()); m_webrequest = new WWW(url, bytes); } else if (isOverrideHost) { System.Array bytes = null; if (head is System.Array) { bytes = (byte[])head; } Dictionary <string, string> headers = new Dictionary <string, string> (); if (cRequest.headers != null) { foreach (var kv in cRequest.headers) { headers[kv.Key] = kv.Value; } } headers["host"] = cRequest.overrideHost; m_webrequest = new WWW(url, (byte[])head, cRequest.headers); } else { m_webrequest = new WWW(url); } }
private void _BeginDownload() { m_Data = null; var head = cRequest.head; string url = CUtils.CheckWWWUrl(cRequest.url); if (head is WWWForm) { m_webrequest = new WWW(url, (WWWForm)head); } else if (head is string) { var bytes = LuaHelper.GetBytes(head.ToString()); m_webrequest = new WWW(url, bytes); } else if (head is System.Array) { m_webrequest = new WWW(url, (byte[])head); } else { m_webrequest = new WWW(url); } }
public void BeginLoad(CRequest req) { this.isFree = false; this._req = req; this.enabled = true; string url = req.url; #if HUGULA_WEB_MODE if (req.isAssetBundle) { url = req.uris.OnOverrideUrl(req); } #endif url = CUtils.CheckWWWUrl(url); #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 if (req.isAssetBundle && req.isLoadFromCacheOrDownload) #else if (req.isNativeFile && req.isAssetBundle && !req.isLoadFromCacheOrDownload) { /* * Stream Compressed (LZMA) Mem: LZ4 compressed bundle size. Perf: reading from disk + LZMA decompression + LZ4 compression. * Chunk Compressed (LZ4) Mem: no extra memory is used. Perf: reading from disk. */ #if UNITY_ANDROID && !UNITY_EDITOR string android_url = req.url; android_url = android_url.Replace(Common.JAR_FILE, "").Replace("apk!/assets", "apk!assets"); abRequest = AssetBundle.LoadFromFileAsync(android_url); #else abRequest = AssetBundle.LoadFromFileAsync(req.url); #endif } else if (req.isAssetBundle && req.isLoadFromCacheOrDownload) #endif { if (CResLoader.assetBundleManifest != null) { www = WWW.LoadFromCacheOrDownload(url, CResLoader.assetBundleManifest.GetAssetBundleHash(req.assetBundleName), 0); } else { www = WWW.LoadFromCacheOrDownload(url, 0); } } else if (req.head is WWWForm) { www = new WWW(url, (WWWForm)req.head); } else if (req.head is byte[]) { www = new WWW(url, (byte[])req.head); } else { www = new WWW(url); } if (www != null) { if (req.priority > 10000) { www.threadPriority = ThreadPriority.High; } else if (req.priority < -10000) { www.threadPriority = ThreadPriority.Low; } else if (req.priority < 0) { www.threadPriority = ThreadPriority.BelowNormal; } } if (abRequest != null) { abRequest.priority = req.priority; } #if HUGULA_LOADER_DEBUG Debug.LogFormat(" 0. <color=#8cacbc> begin load : url({0}),key:({1}) assetName({2}) abName({3}) isNativeFile({4}) isAssetBundle({5}) frame{6} )</color>", url, req.key, req.assetName, req.assetBundleName, req.isNativeFile, req.isAssetBundle, Time.frameCount); #endif }