public static int constructor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); CRequest o; if(argc==2){ System.String a1; checkType(l,2,out a1); o=new CRequest(a1); pushValue(l,true); pushValue(l,o); return 2; } else if(argc==4){ System.String a1; checkType(l,2,out a1); System.String a2; checkType(l,3,out a2); System.String a3; checkType(l,4,out a3); o=new CRequest(a1,a2,a3); pushValue(l,true); pushValue(l,o); return 2; } return error(l,"New object failed."); } catch(Exception e) { return error(l,e); } }
private IEnumerator CompareAndroidVersion() { ReadPersistentVersion(); string path = Application.streamingAssetsPath + "/" + VERSION_FILE_NAME; WWW www = new WWW(path); yield return www; this.streamingVersion = int.Parse(www.text.Trim()); Debug.Log(string.Format(" persistentVersion= {0},streamingVersion = {1}", this.persistentVersion, this.streamingVersion)); if (this.persistentVersion < this.streamingVersion)// copy streaming to persistent { string fileName = Application.streamingAssetsPath + "/data.zip";// --System.IO.Path.ChangeExtension(Application.streamingAssetsPath,".zip"); CRequest req = new CRequest(fileName); req.OnComplete += delegate(CRequest r) { byte[] bytes = null; if (r.data is WWW) { WWW www1 = r.data as WWW; bytes = www1.bytes; } FileHelper.UnZipFile(bytes, Application.persistentDataPath); LuaBegin(); }; this.multipleLoader.LoadReq(req); } else { LuaBegin(); } }
public void BeginLoad(CRequest req) { isFree=false; this._req = req; // Debug.Log("BeginLoad : url "+req.url+" \n key:"+req.key); StopCoroutine (Loadres ()); StartCoroutine(Loadres()); }
//开始加载场景 public static void BeginLoadScene() { ResourcesLoader.OnAssetBundleComplete = OnSharedComplete; CUtils.DebugCastTime("LoadingFirst.BeginLoadScene"); var req = CRequest.Get(); req.relativeUrl = CUtils.GetRightFileName(sceneAssetBundleName); req.assetName = sceneName; req.OnComplete = OnSceneAbLoaded; req.OnEnd = OnSceneAbError; req.assetType = CacheManager.Typeof_ABScene; CacheManager.Unload(req.keyHashCode); ResourcesLoader.LoadAsset(req); }
static public int set_times(IntPtr l) { try { CRequest self = (CRequest)checkSelf(l); System.Int32 v; checkType(l, 2, out v); self.times = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_childrenReq(IntPtr l) { try { CRequest self = (CRequest)checkSelf(l); CRequest v; checkType(l, 2, out v); self.childrenReq = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_www(IntPtr l) { try { CRequest self = (CRequest)checkSelf(l); UnityEngine.WWW v; checkType(l, 2, out v); self.www = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_userData(IntPtr l) { try { CRequest self = (CRequest)checkSelf(l); System.Object v; checkType(l, 2, out v); self.userData = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
/// <summary> /// Load the specified localization dictionary. /// </summary> static bool LoadDictionary(string value) { if (value.Equals(SystemLanguage.ChineseSimplified.ToString())) { value = SystemLanguage.Chinese.ToString(); } string assetName = Common.LANGUAGE_PREFIX + value.ToLower(); string abName = CUtils.GetRightFileName(assetName + Common.CHECK_ASSETBUNDLE_SUFFIX); CRequest req = CRequest.Get(); req.relativeUrl = abName; req.assetName = assetName; req.assetType = typeof(BytesAsset); req.async = false; var uri = new UriGroup(); uri.Add(CUtils.GetRealPersistentDataPath(), true); uri.Add(CUtils.GetRealStreamingAssetsPath()); req.uris = uri; req.OnComplete += delegate(CRequest req1) { BytesAsset main = req1.data as BytesAsset; //www.assetBundle.mainAsset as TextAsset; byte[] txt = main.bytes; #if UNITY_EDITOR Debug.Log(mLanguage + " is loaded " + txt.Length + " " + Time.frameCount); #endif if (txt != null) { Load(txt); } SelectLanguage(mLanguage); CacheManager.Unload(req1.keyHashCode); localizationHasBeenSet = true; }; req.OnEnd += delegate(CRequest req1) { if (!value.ToLower().Equals(SystemLanguage.English.ToString().ToLower())) { language = SystemLanguage.English.ToString(); } }; ResourcesLoader.LoadAsset(req); return(false); }
/// <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); }
/// <summary> /// 更新昵称信息 /// </summary> private void UpdateNiCheng() { UserInfo user = Session["user"] as UserInfo; string relName = CRequest.GetString("relName"); if (user != null) { int num = UserInfoService.UpdateNiCheng(user, relName); Response.Write("success"); } else { Response.Write("fail"); } }
/// <summary> /// 根据组策略校验request.url的crc值。 /// 文件不存在或者校验失败返回false /// </summary> /// <param name="req"></param> /// <returns></returns> public static bool CheckUriCrc(CRequest req) { bool check = ManifestManager.CheckReqCrc(req); //CheckLocalFileCrc(req.url, out crc); if (!check) { var re = UriGroup.CheckAndSetNextUriGroup(req); //CUtils.SetRequestUri(req, 1); #if HUGULA_LOADER_DEBUG HugulaDebug.FilterLogFormat(req.key, "<color=#ffff00>CrcCheck.CheckUriCrc Req(assetname={0},url={1}) CheckFileCrc=false,SetNextUri={2}</color>", req.assetName, req.url, re); #endif return(re); } return(true); }
/// <summary> /// 催乳师认证 /// </summary> private void User2Credit() { int id = CRequest.GetInt("id", 0); int type = CRequest.GetInt("num", 0); int num = UserInfoService.CreditUser(id, type); if (num > 0) { Response.Write("success"); } else { Response.Write("fail"); } }
public virtual void RegisterUser() { var url = CTaskUtil.REGISTER_URL; var header = CTaskUtil.VERIFY_HEADERS; var registerParam = new Dictionary <string, string> (); registerParam ["uname"] = this.currentUser.userName; registerParam ["upass"] = this.currentUser.userPassword; registerParam ["uemail"] = this.currentUser.userEmail; registerParam ["udisplayname"] = this.currentUser.userDisplayName; registerParam ["uloginmethod"] = "ANDROID"; bool canSubmit = string.IsNullOrEmpty(this.currentUser.userName) == false && string.IsNullOrEmpty(this.currentUser.userPassword) == false && string.IsNullOrEmpty(this.currentUser.userEmail) == false && string.IsNullOrEmpty(this.currentUser.userDisplayName) == false; if (canSubmit) { var request = new CRequest(url, header); request.Post(url, registerParam, (CResult obj) => { var objContent = obj.ToJSONObject(); if (objContent.ContainsKey("resultCode")) { var userResponse = objContent ["resultContent"] as Dictionary <string, object>; currentUser.userName = userResponse ["userName"].ToString(); currentUser.userEmail = userResponse ["userEmail"].ToString(); currentUser.userDisplayName = userResponse ["userDisplayName"].ToString(); currentUser.token = userResponse ["token"].ToString(); this.OnClientRegisterCompleted(currentUser); } else if (objContent.ContainsKey("errorCode")) { var errorContent = objContent ["errorContent"].ToString(); this.OnClientError(errorContent); } }, (err) => { this.OnClientError(err); }, null); // Start loading UI. CUICustomManager.Instance.ActiveLoading(true); } else { this.OnClientError("Field do not empty."); } // INIT this.m_Inited = false; }
/// <summary> /// 设置产品属性赞 /// </summary> private void SetGoods() { int id = CRequest.GetInt("pid", 0); int num = CRequest.GetInt("num", 0); int row = ProductGoodsService.SetGoods(num, id); if (row > 0) { int goods = ProductGoodsService.GetGoods(num, id); Response.Write(goods.ToString()); } else { Response.Write("0"); } }
/// <summary> /// 更新资讯的浏览次数 /// </summary> private void updateViewsCount() { int id = CRequest.GetInt("id", 0); NewsService.UpdateViews(id); News item = NewsService.GetModel(id); if (item != null) { Response.Write(item.res_views); } else { Response.Write("0"); } }
/// <summary> /// 根据组策略校验request.url的crc值。 /// 文件不存在或者校验失败返回false /// </summary> /// <param name="req"></param> /// <returns></returns> public static bool CheckUriCrc(CRequest req) { uint crc = 0; bool check = CheckLocalFileCrc(req.url, out crc); if (!check) { var re = UriGroup.CheckAndSetNextUriGroup(req); //CUtils.SetRequestUri(req, 1); #if HUGULA_LOADER_DEBUG Debug.LogFormat("<color=#ff0000>CrcCheck.CheckUriCrc Req(assetname={0},url={1}) crc={2},CheckFileCrc=false,SetNextUri={3}</color>", req.assetName, req.url, crc, re); #endif return(re); } return(true); }
/// <summary> /// 回复评价信息 /// </summary> private void ReplyComment() { UserInfo user = Session["user"] as UserInfo; if (user == null) { Response.Write("login"); } else { int id = CRequest.GetInt("id", 0); string replyContent = CRequest.GetString("replyContent"); Reply item = new Reply(); item.commentId = id; Comment comItem = CommentService.GetModel(id); if (comItem.addUser == user.id) { Response.Write("self"); return; } item.replyContent = replyContent; item.status = 0; item.remark = ""; item.addTime = DateTime.Now; item.addUser = user.id; item.infoType = 0; int num = ReplyService.Add(item); StringBuilder sb = new StringBuilder(); if (num > 0) { DataSet ds = ReplyService.GetList("commentId = " + id); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { UserInfo replyUser = UserInfoService.GetModel(Convert.ToInt32(dr["addUser"])); if (replyUser != null) { sb.Append(replyUser.username + ":" + dr["replyContent"].ToString() + "<br/>"); } } } } Response.Write(sb.ToString()); } }
/// <summary> /// 设置PK对象 /// </summary> private void AddPK() { int id = CRequest.GetInt("id", 0); if (Session["PK1"] != null && Session["PK2"] != null) { Response.Write("full"); return; } else { Product item = ProductService.GetModel(id); if (Session["PK1"] == null) { if (Session["PK2"] != null) { Product item2 = Session["PK2"] as Product; if (item.id == item2.id) { Response.Write("exists"); return; } } if (item != null) { Session["PK1"] = item; } } else { Product item2 = Session["PK1"] as Product; if (item2.id == item.id) { Response.Write("exists"); return; } if (Session["PK2"] == null) { if (item != null) { Session["PK2"] = item; } } } } Response.Write("success"); }
protected virtual void LoadComplete(CTransport loader, CRequest creq, IList <CRequest> depens) { RemoveRequest(creq); if (depens != null) //if have depens { currentLoaded++; CRequest req1 = null; creq.dependenciesCount = depens.Count; for (int i = 0; i < depens.Count; i++) //被依赖项目 { req1 = depens[i]; req1.OnComplete += OnDependencyComp; req1.OnEnd += OnDependencyComp; req1.childrenReq = creq; if (CacheManager.SetRequestDataFromCache(req1)) { req1.DispatchComplete(); continue; } LoadReq(req1); } } else { CacheManager.SetRequestDataFromCache(creq); if (creq.isShared) { if (OnSharedComplete != null) { OnSharedComplete(creq); } } else { currentLoaded++; } Callbacklist(creq); BeginQueue(); CheckAllComplete(); } }
public void ProcessRequest(HttpContext context) { HttpRequest requ = context.Request; HttpResponse res = context.Response; string filename = CRequest.GetString("fn"); if (!File.Exists(context.Server.MapPath(filename))) { context.Response.Write("文件不存在,或者已经被管理员Delete!"); context.Response.End(); } if (filename != "" && filename.IndexOf("/") >= 0) { DoFile.ResponseFile(requ, res, filename.Substring(filename.LastIndexOf("/") + 1), context.Server.MapPath(filename), 10233); } }
/// <summary> /// 从缓存设置数据 /// </summary> /// <param name="req"></param> public static bool SetRequestDataFromCache(CRequest req) { bool re = false; int keyhash = req.keyHashCode; CacheData cachedata = GetCache(keyhash); if (cachedata != null) { AssetBundle abundle = cachedata.assetBundle; System.Type assetType = LuaHelper.GetType(req.assetType); if (assetType == null) { assetType = typeof(UnityEngine.Object); } if (req.isShared) //共享的 { req.data = abundle; re = true; } else if (assetType.Equals(Typeof_String)) { WWW www = cachedata.www; req.data = new string[] { www.text }; re = true; } else if (assetType.Equals(Typeof_Bytes)) { WWW www = cachedata.www; req.data = www.bytes; re = true; } else if (assetType.IsArray || assetType.Equals(Typeof_AssetBundle)) { req.data = abundle;//.LoadAllAssets(assetType.UnderlyingSystemType); re = true; } else if (!assetType.IsArray) { req.data = abundle.LoadAsset(req.assetName, assetType); re = true; } } return(re); }
//开始加载场景 internal static void BeginLoadScene(string beginLua) { ManifestManager.LoadUpdateFileManifest(null); PLua.DestoryLua(); PLua.enterLua = beginLua; CUtils.DebugCastTime("LoadingFirst"); var req = CRequest.Get(); req.relativeUrl = CUtils.GetRightFileName(sceneAssetBundleName); req.assetName = sceneName; req.OnComplete = OnSceneAbLoaded; req.OnEnd = OnSceneAbError; req.assetType = CacheManager.Typeof_ABScene; req.async = true; ResourcesLoader.LoadAsset(req); ResourcesLoader.OnAssetBundleComplete = OnSharedComplete; }
protected void Callbacklist(CRequest creq) { IList <CRequest> callbacklist = requestCallBackList[creq.udKey]; if (callbacklist != null) { requestCallBackList.Remove(creq.udKey); int count = callbacklist.Count; object data = creq.data; CRequest reqitem; for (int i = 0; i < count; i++) {// reqitem in callbacklist) reqitem = callbacklist[i]; reqitem.data = data; reqitem.DispatchComplete(); } callbacklist.Clear(); } }
protected void OnDependencyComp(CRequest req) { CRequest childReq = req.childrenReq; if (childReq != null) { childReq.dependenciesCount--; if (childReq.dependenciesCount <= 0) { object data = SetReqDataFromWWW(childReq, childReq.www); if (childReq.cache || childReq.isShared) { SetCache(childReq.key, data); } Callbacklist(childReq); } } BeginQueue(); CheckAllComplete(); }
protected void AddReqToQueue(CRequest req) { string key = req.udKey; if (CacheManager.SetRequestDataFromCache(req)) //如果有缓存 { req.DispatchComplete(); } else if (requestCallBackList.ContainsKey(key)) { requestCallBackList[key].Add(req); } else { requestCallBackList[key] = new List <CRequest>(); requestCallBackList[key].Add(req); queue.Add(req); if (queue.Size() == 0 && currentLoading == 0) { totalLoading = 1; currentLoaded = 0; } else if (!req.isShared) { totalLoading++; } if (pushGroup && !req.isShared) //如果是一组 { if (currGroupRequest == null) { currGroupRequest = _currGroupRequestRef; } currGroupRequest.Add(req); } } }
public CLoadingResourceTask() : base() { this.taskName = "LoadingResource"; var firstSetting = PlayerPrefs.GetInt(CTaskUtil.GAME_FIRST_LAUNCH, 0) == 1; var host = CTaskUtil.Get(CTaskUtil.HOST); if (firstSetting == false) { this.nextTask = "LocalSetting"; } else { this.nextTask = "SelectSong"; } #if UNITY_EDITOR || UNITY_STANDALONE this.m_Request = new CRequest(host + "/version?plf=standalone"); #else this.m_Request = new CRequest(host + "/version?plf=android"); #endif this.m_CurrentTime = DateTime.Now.Ticks; this.m_OnLoadingProcess = false; }
/// <summary> /// Load the specified localization dictionary. /// </summary> static bool LoadDictionary(string value) { if (value.Equals(SystemLanguage.ChineseSimplified.ToString())) { value = SystemLanguage.Chinese.ToString(); } var loader = LResLoader.instance; string assetName = Common.LANGUAGE_PREFIX + value.ToLower(); string abName = CUtils.GetRightFileName(assetName + Common.CHECK_ASSETBUNDLE_SUFFIX); CRequest req = new CRequest(abName, assetName, typeof(TextAsset)); req.OnComplete += delegate(CRequest req1) { 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); CacheManager.Unload(req1.keyHashCode); localizationHasBeenSet = true; }; req.OnEnd += delegate(CRequest req1) { if (!value.ToLower().Equals(SystemLanguage.English.ToString().ToLower())) { language = SystemLanguage.English.ToString(); } }; loader.LoadReq(req); return(false); }
protected void OnDependencyComp(CRequest req) { CRequest childReq = req.childrenReq; CountMananger.Add(req.keyHashCode); //引用数量加1 if (childReq != null) { childReq.dependenciesCount--; if (childReq.dependenciesCount <= 0) { CacheManager.SetRequestDataFromCache(childReq); if (childReq.isShared && OnSharedComplete != null) { OnSharedComplete(childReq); } Callbacklist(childReq); } } BeginQueue(); CheckAllComplete(); }
protected void LoadError(CTransport cloader, CRequest creq) { CRequest req = cloader.req; #if UNITY_EDITOR Debug.LogWarning("load Error : times=" + req.times + " url=" + req.url + " key= " + req.key); #endif RemoveRequest(req); RemoveCallbacklist(creq); if (req.times < 2) { req.priority = req.priority - 10; this.AddReqToQueue(req); this.BeginQueue(); } else { req.DispatchEnd(); BeginQueue(); CheckAllComplete(); } }
/// <summary> /// 获取子级信息 /// </summary> private void GetMoreAreaInfo() { StringBuilder sb = new StringBuilder(); string areaId = CRequest.GetString("areaId"); DataSet ds = UserBaseService.GetList("regCode = '" + areaId + "'"); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["fullName"].ToString().Length > 12) { sb.Append("<li style=\"float:left; width:18%; line-height:35px; text-align:center; padding:5px; margin-bottom:5px; border:1px #eee solid;\"><a href=\"/comDetail_client_" + dr["userId"] + "_1.html\" title=\"" + dr["fullName"] + "\">" + dr["fullName"].ToString().Substring(0, 12) + "</a></li> "); } else { sb.Append("<li style=\"float:left; width:18%; line-height:35px; text-align:center; padding:5px; margin-bottom:5px; border:1px #eee solid;\"><a href=\"/comDetail_client_" + dr["userId"] + "_1.html\" title=\"" + dr["fullName"] + "\">" + dr["fullName"] + "</a></li> "); } } sb.Append("<li style=\"float:left; width:18%; line-height:35px; text-align:center; padding:5px; margin-bottom:5px; border:1px #eee solid;\"><a href='javascript:collapseInfo(" + areaId + ")'>收起 <<</a></li> "); } Response.Write(sb.ToString()); }
protected bool LoadRequest(CRequest req) { string key = req.udKey; CTransport load = this.GetFreeLoader(); // new GameObject(); if (load != null) { req.times++; load.key = key; loader[key] = req; //#if UNITY_EDITOR // Debug.Log ("-----------beginLoad <<:" + req.key + ">> shared=" + req.isShared + ",currentLoading=" + this.currentLoading + " max=" + this.maxLoading); //#endif load.BeginLoad(req); return(true); } else { #if UNITY_EDITOR //Debug.Log ("-----------no free transport <<:" + req.key + ">> shared=" + req.isShared + ",currentLoading=" + this.currentLoading + " max=" + this.maxLoading); #endif } return(false); }
protected void AddReqToQueue(CRequest req) { string key = req.udKey; if (requestCallBackList.ContainsKey(key)) { requestCallBackList[key].Add(req); } else { requestCallBackList[key] = new List<CRequest>(); requestCallBackList[key].Add(req); queue.Add(req); if (queue.Size() == 0 && currentLoading == 0) { totalLoading = 1; currentLoaded = 0; } else if (!req.isShared) { totalLoading++; } } }
//asset_loader.lua on_assets_load逻辑 public static void OnAssetsLoad(CRequest req, LuaTable asset) { var main = (GameObject)req.data; var root = LuaHelper.Instantiate(main); root.name = main.name; //set root refer asset["root"] = root; // var refer = root.GetComponentInChildren<ReferGameObjects>(true); // asset["refer"] = refer; //set child Transform pr = root.transform; int count = pr.childCount; Transform child = null; LuaTable items = (LuaTable)asset["items"]; for (int i = 0; i < count; i++) { child = pr.GetChild(i); items[child.name] = child.gameObject; } }
static void OnSceneAbLoaded(CRequest req) { }
/// <summary> /// 移除引用记录 /// </summary> /// <param name="keyhash"></param> static void RemoveReferenceRecord(CRequest creq) { int keyhash = creq.keyHashCode; if (referenceRecord.ContainsKey(keyhash)) { int refc = referenceRecord[keyhash]; CountMananger.Add(keyhash, refc);//真实引用 referenceRecord.Remove(keyhash); } }
protected void RemoveRequest(CRequest req) { string key = req.udKey; CRequest load = loader[key]; loader.Remove(key); // load.Dispose(); // load=null; }
static int CompareFunc (CRequest a, CRequest b) { if (a.priority <b.priority) return 1; if (a.priority > b.priority) return -1; return 0; }
private void OnCompHandler(CRequest req) { if (onCompleteFn != null) onCompleteFn.call(req); }
protected void RemoveCallbacklist(CRequest creq) { if (requestCallBackList.ContainsKey(creq.udKey)) { requestCallBackList.Remove(creq.udKey); } }
protected void Callbacklist(CRequest creq) { IList<CRequest> callbacklist = requestCallBackList[creq.udKey]; if (callbacklist != null) { requestCallBackList.Remove(creq.udKey); int count = callbacklist.Count; object data = creq.data; CRequest reqitem; for (int i = 0; i < count; i++) {// reqitem in callbacklist) reqitem = callbacklist[i]; reqitem.data = data; reqitem.DispatchComplete(); } callbacklist.Clear(); } }
static void OnSceneAbError(CRequest req) { BeginLoadScene(); }
protected void RemoveRequest(CRequest req) { string key = req.udKey; CRequest load = loader[key]; loader.Remove(key); }
private void DispatchErrorEvent(CRequest cReq) { if (OnError != null) { OnError (this, cReq); } }
private void DispatchCompleteEvent(CRequest cReq,IList<CRequest> dependencies) { if(OnComplete!=null) OnComplete(this,cReq,dependencies); }
/// <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; }
protected bool LoadRequest(CRequest req) { string key = req.udKey; CTransport load = this.GetFreeLoader(); // new GameObject(); if (load != null) { req.times++; load.key = key; loader[key] = req; //#if UNITY_EDITOR // Debug.Log ("-----------beginLoad <<:" + req.key + ">> shared=" + req.isShared + ",currentLoading=" + this.currentLoading + " max=" + this.maxLoading); //#endif load.BeginLoad(req); return true; } else { #if UNITY_EDITOR //Debug.Log ("-----------no free transport <<:" + req.key + ">> shared=" + req.isShared + ",currentLoading=" + this.currentLoading + " max=" + this.maxLoading); #endif } return false; }
protected void OnDependencyComp(CRequest req) { CRequest childReq = req.childrenReq; if (childReq != null) { childReq.dependenciesCount--; if (childReq.dependenciesCount <= 0) { object data = SetReqDataFromWWW(childReq, childReq.www); if (childReq.cache || childReq.isShared) SetCache(childReq.key, data); Callbacklist(childReq); } } BeginQueue(); CheckAllComplete(); }
public void Add(CRequest req) { queue.Add(req); queue.Sort(CompareFunc); }
protected virtual void LoadComplete(CTransport loader, CRequest creq, IList<CRequest> depens) { RemoveRequest(creq); if (depens != null) //if have depens { currentLoaded++; CRequest req1 = null; creq.dependenciesCount = depens.Count; string key = string.Empty; for (int i = 0; i < depens.Count; i++) { req1 = depens[i]; req1.OnComplete += OnDependencyComp; req1.OnEnd += OnDependencyComp; req1.childrenReq = creq; key = req1.key; object cacheData = GetCache(key); if (cacheData != null) { SetReqDataFromData(req1, cacheData); req1.DispatchComplete(); continue; } LoadReq(req1); } } else { object data = SetReqDataFromWWW(creq, creq.www); if (creq.isShared) { if (OnSharedComplete != null) OnSharedComplete(creq); } else if (creq.cache) { SetCache(creq.key, data); currentLoaded++; } else { currentLoaded++; } Callbacklist(creq); BeginQueue(); CheckAllComplete(); } }
/// <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; 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; }
protected void OnDependencyComp(CRequest req) { CRequest childReq = req.childrenReq; if (childReq != null) { childReq.dependenciesCount--; if (childReq.dependenciesCount <= 0) { object data = SetReqDataFromWWW(childReq, childReq.www); if (childReq.cache || childReq.isShared) SetCache(childReq.key, data); //Debug.Log("_______loadComplete <<" + childReq.key + ">> depens:" + req.key + " count:" + childReq.dependenciesCount.ToString()); Callbacklist(childReq); } } //Debug.Log("OnDependencyComp <<" + req.key + ">> is complete "); BeginQueue(); CheckAllComplete(); }
private void OnEndHandler(CRequest req) { if (onEndFn != null) onEndFn.call(req); }
protected virtual object SetReqDataFromWWW(CRequest req, WWW www) { object re = null; AssetBundle abundle = www.assetBundle; System.Type assetType = LuaHelper.GetType(req.assetType); if (assetType == null) assetType = typeof(UnityEngine.Object); if (assetType.Equals(typeof(System.String))) { req.data = new string[] { www.text }; req.assetBundle = null; re = req.data; } else if (assetType.Equals(typeof(System.Byte[]))) { req.data = www.bytes; req.assetBundle = null; re = req.data; } else if (!assetType.IsArray) { re = req.assetBundle; req.data = req.assetBundle.LoadAsset(req.assetName, assetType); } else if (assetType.IsArray) { req.data = req.assetBundle.LoadAllAssets(assetType); re = req.assetBundle; } // www.Dispose(); return re; }
static void PushGroup(CRequest req) { if (currGroupRequests == null) currGroupRequests = currGroupRequestsRef; currGroupRequests.Add(req); }
public static void SetReqDataFromData(CRequest req, object data) { System.Type assetType = LuaHelper.GetType(req.assetType); if (assetType == null) assetType = typeof(GameObject); if (data is AssetBundle) { req.assetBundle = data as AssetBundle; if(req.assetBundle!=null) { if (!assetType.IsArray) { req.data = req.assetBundle.LoadAsset(req.assetName, assetType); } else { req.data = req.assetBundle.LoadAllAssets(assetType); } } } else if (data.GetType() == typeof(System.String)) { req.data = data; } else if (data.GetType() == typeof(System.Byte[])) { req.data = data; } }
void LHighway_onSharedComplete(CRequest req) { if (onSharedCompleteFn != null) onSharedCompleteFn.Call(req); }
public void LoadReq(CRequest req) { AddReqToQueue(req); BeginQueue(); }
protected virtual void LoadComplete(CTransport loader, CRequest creq, IList<CRequest> depens) { //#if UNITY_EDITOR // if (creq.isShared) // Debug.Log("_______loadComplete <<" + creq.key + ">> is Shared "); // else // Debug.Log("______loadComplete <<" + creq.key + ">> depens:" + (depens != null).ToString()); //#endif RemoveRequest(creq); if (depens != null) //if have depens { currentLoaded++; CRequest req1 = null; creq.dependenciesCount = depens.Count; string key = string.Empty; //Debug.Log("______begin load<" + creq.key + "> and depens :" + depens.Count.ToString()); for (int i = 0; i < depens.Count; i++) { req1 = depens[i]; req1.OnComplete += OnDependencyComp; req1.OnEnd += OnDependencyComp; req1.childrenReq = creq; key = req1.key; object cacheData = GetCache(key); if (cacheData != null) { SetReqDataFromData(req1, cacheData); req1.DispatchComplete(); continue; } LoadReq(req1); } } else { //Debug.Log("______loadComplete:<" + creq.key + "> "); object data = SetReqDataFromWWW(creq, creq.www); if (creq.isShared) { if (OnSharedComplete != null) OnSharedComplete(creq); } else if (creq.cache) { SetCache(creq.key, data); currentLoaded++; } Callbacklist(creq); BeginQueue(); CheckAllComplete(); } }