/// <summary> /// lua bundle /// </summary> /// <returns></returns> private IEnumerator loadLuaBundle(bool domain, LuaFunction onLoadedFn) { string keyName = ""; string luaP = CUtils.GetAssetFullPath("font.u3d"); WWW luaLoader = new WWW(luaP); yield return(luaLoader); if (luaLoader.error == null) { byte[] byts = CryptographHelper.Decrypt(luaLoader.bytes, DESHelper.instance.Key, DESHelper.instance.IV); AssetBundle item = AssetBundle.CreateFromMemoryImmediate(byts); TextAsset[] all = item.LoadAllAssets <TextAsset>(); foreach (var ass in all) { keyName = ass.name; luacache[keyName] = ass; } item.Unload(false); luaLoader.Dispose(); } DoUnity3dLua(); if (domain) { DoMain(); } if (onLoadedFn != null) { onLoadedFn.Call(); } }
// IEnumerator Loadres() // { //// Debug.Log("StartCoroutine Loadres : url "+req.url+" \n key:"+req.key); // if(req.head is WWWForm) // { // www=new WWW(req.url,(WWWForm)req.head); // }else if(req.head is byte[]) // { // www = new WWW(req.url, (byte[])req.head); // } // else // { // www=new WWW(req.url); //WWW.LoadFromCacheOrDownload(req.url,1); // } //// Debug.Log("StartCoroutine www : url "+req.url+" \n key:"+req.key); // yield return www; // if(www.error!=null) // { // Debug.LogWarning("error : url "+req.url+" \n error:"+www.error); // isFree =true; // DispatchErrorEvent(req); // } // else // { // if(OnProcess!=null) // OnProcess(this,1); // //Debug.Log("will complete : url " + req.url + " \n key:" + req.key); // try // { // CacheData cacheData = new CacheData(www, www.assetBundle, req.key);//缓存 // CacheManager.AddCache(cacheData); // IList<CRequest> depens = null; // if(m_AssetBundleManifest!=null) // { // string[] deps = m_AssetBundleManifest.GetAllDependencies(req.assetBundleName); // depens = GetDependencies(deps); // int[] alldepens = GetDependenciesHashCode(deps); // cacheData.allDependencies = alldepens; // }else if (m_AssetBundleManifest == null) // { // Debug.LogWarning(req.key+"Please initialize AssetBundleManifest"); // } // isFree =true; // this.DispatchCompleteEvent(this.req,depens); // } // catch (Exception e) // { // Debug.LogError(e); // } // } // } /// <summary> /// get Dependencies req /// </summary> /// <returns>The dependencies.</returns> /// <param name="script">Script.</param> private IList <CRequest> GetDependencies(string[] paths) { if (paths == null || paths.Length == 0) { return(null); } IList <CRequest> reqs = new List <CRequest>(); CRequest item; int priority = this.req.priority + 10; foreach (string p in paths) { item = new CRequest(CUtils.GetAssetFullPath(RemapVariantName(p))); item.isShared = true; item.priority = priority; reqs.Add(item); } if (reqs.Count > 0) { return(reqs); } else { return(null); } }
static public int GetAssetFullPath_s(IntPtr l) { try { System.String a1; checkType(l, 1, out a1); var ret = CUtils.GetAssetFullPath(a1); pushValue(l, ret); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
/// <summary> /// 加载lua bundle /// </summary> /// <returns></returns> private IEnumerator loadLuaBundle(bool domain, LuaFunction onLoadedFn) { string keyName = ""; string luaP = CUtils.GetAssetFullPath("font.u3d"); //Debug.Log("load lua bundle" + luaP); WWW luaLoader = new WWW(luaP); yield return(luaLoader); if (luaLoader.error == null) { byte[] byts = CryptographHelper.Decrypt(luaLoader.bytes, DESHelper.instance.Key, DESHelper.instance.IV); AssetBundle item = AssetBundle.CreateFromMemoryImmediate(byts); // item = luaLoader.assetBundle; #if UNITY_5 TextAsset[] all = item.LoadAllAssets <TextAsset>(); foreach (var ass in all) { keyName = Regex.Replace(ass.name, @"\.", ""); //Debug.Log("cache : " + keyName); luacache[keyName] = ass; } #else UnityEngine.Object[] all = item.LoadAll(typeof(TextAsset)); foreach (var ass in all) { keyName = Regex.Replace(ass.name, @"\.", ""); Debug.Log(keyName + " complete"); luacache[keyName] = ass as TextAsset; } #endif //Debug.Log("loaded lua bundle complete" + luaP); // luaLoader.assetBundle.Unload(false); item.Unload(false); luaLoader.Dispose(); } DoUnity3dLua(); if (domain) { DoMain(); } if (onLoadedFn != null) { onLoadedFn.call(); } }
/// <summary> /// Load the specified localization dictionary. /// </summary> static bool LoadDictionary(string value) { LHighway loader = LHighway.instance; string fileName = Common.LANGUAGE_FLODER + "/" + value.ToLower() + "." + Common.LANGUAGE_SUFFIX; //fileName = CUtils.GetAssetFullPath(fileName); //string exsi = CUtils.GetFileFullPathNoProtocol(fileName); string url = ""; //if (!System.IO.File.Exists(exsi)) //{ // url = CUtils.GetFileFullPath(Common.LANGUAGE_FLODER + "/english." + Common.LANGUAGE_SUFFIX); // mLanguage = "English"; //} //else { url = CUtils.GetAssetFullPath(fileName); } CRequest req = new CRequest(url, "", "TextAsset"); req.OnComplete += delegate(CRequest req1) { //WWW www =((WWW)req1.data); TextAsset main = req1.data as TextAsset; //www.assetBundle.mainAsset as TextAsset; byte[] txt = main.bytes; #if UNITY_EDITOR Debug.Log(mLanguage + " is loaded " + txt.Length); #endif if (txt != null) { Load(txt); } SelectLanguage(mLanguage); //req1.assetBundle.Unload(true); //www.Dispose(); //www = null; CacheManager.ClearCache(req1.keyHashCode); localizationHasBeenSet = true; }; req.OnEnd += delegate(CRequest req1) { url = CUtils.GetFileFullPath(Common.LANGUAGE_FLODER + "/english." + Common.LANGUAGE_SUFFIX); mLanguage = "English"; req1.url = url; loader.LoadReq(req1); }; loader.LoadReq(req); return(false); }