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 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(); } }
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(); } }
protected void OnProcess(CTransport loader, float progress) { loadingEvent.target = this; if (totalLoading <= 0) loadingEvent.total = 1; else loadingEvent.total = totalLoading; if (loadingEvent.current < currentLoaded) loadingEvent.current = currentLoaded; loadingEvent.progress = progress; if (OnProgress != null && totalLoading > 0) { OnProgress(this, loadingEvent); } }
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(); } }