Exemple #1
0
        /// <summary>
        /// dispatch request event
        /// </summary>
        /// <param name="req"></param>
        /// <param name="isError"></param>
        static internal void DispatchReqAssetOperation(CRequest req, bool isError)
        {
            var group = req.group;

            currLoaded++;

            OnProcess();
            try {
                if (isError)
                {
                    req.DispatchEnd();
                }
                else
                {
                    req.DispatchComplete();
                }
            } catch (System.Exception e) {
                Debug.LogError(e);
            }

            if (group != null)
            {
                group.Complete(req, isError);
            }

            req.ReleaseToPool();
        }
Exemple #2
0
        /// <summary>
        /// dispatch request event
        /// </summary>
        /// <param name="req"></param>
        /// <param name="isError"></param>
        static internal void DispatchReqAssetOperation(CRequest req, bool isError, int opID, bool backPool = true)
        {
            currLoaded++;

            OnProcess();
            try
            {
                if (isError)
                {
                    req.DispatchEnd();
                }
                else if (opID == 0 || completeOper.Contains(opID)) //正常回调
                {
                    completeOper.Remove(opID);
                    req.DispatchComplete();
                }
                else
                {
                    req.DispatchEnd();
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
            }

            if (backPool)
            {
                req.ReleaseToPool();
            }
        }
Exemple #3
0
        /// <summary>
        /// dispatch request event
        /// </summary>
        /// <param name="req"></param>
        /// <param name="isError"></param>
        static internal void DispatchReqAssetOperation(CRequest req, bool isError)
        {
            var group = req.group;

            if (isError)
            {
                req.DispatchEnd();
            }
            else
            {
                req.DispatchComplete();
            }

            if (group != null)
            {
                group.Complete(req, isError);
            }
#if HUGULA_PROFILER_DEBUG && !HUGULA_NO_LOG
            var now = System.DateTime.Now;
            var dt1 = now - req.beginQueueTime;
            var dt2 = now - req.beginLoadTime;
            Debug.LogFormat("<color=#0a9a0a>asset complete Request(asset={0},key={1}) alltime={2},loadtime={3};frame={4}</color>", req.assetName, req.key, dt1.TotalSeconds, dt2.TotalSeconds, Time.frameCount);
#endif

            req.ReleaseToPool();
        }
Exemple #4
0
        /// <summary>
        /// real load assetbundle
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        static protected AssetBundleDownloadOperation LoadAssetBundleInternal(CRequest req)
        {
            AssetBundleDownloadOperation abDownloadOp = null;

            if (!downloadingBundles.TryGetValue(req.key, out abDownloadOp))
            {
                req.url = GetAssetBundleDownloadingURL(req.vUrl); // set full url

                if (req.url.StartsWith(Common.HTTP_STRING))       //load assetbunlde
                {
                    abDownloadOp = AssetBundleDownloadFromWebOperation.Get();
                }
                else
                {
                    abDownloadOp = AssetBundleDownloadFromDiskOperation.Get();
                }
                abDownloadOp.SetRequest(req);
                downloadingBundles.Add(req.key, abDownloadOp);

                CacheData cached = null;
                CacheManager.CreateOrGetCache(req.keyHashCode, out cached);//cache data
                inProgressBundleOperations.Add(abDownloadOp);
                abDownloadOp.BeginDownload();

#if HUGULA_LOADER_DEBUG
                HugulaDebug.FilterLogFormat(req.key, "<color=#10f010>1.2 LoadAssetBundleInternal Request(key={0},isShared={1},assetname={2},dependencies.count={4})keyHashCode{3}, frameCount{5}</color>", req.key, req.isShared, req.assetName, req.keyHashCode, req.dependencies == null ? 0 : req.dependencies.Length, Time.frameCount);
#endif
            }
            else if (req.isShared)
            {
                req.ReleaseToPool();
            }

            return(abDownloadOp);
        }
Exemple #5
0
        /// <summary>
        /// real load assetbundle
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        static protected AssetBundleDownloadOperation LoadAssetBundleInternal(CRequest req)
        {
            AssetBundleDownloadOperation abDownloadOp = null;

            if (!downloadingBundles.TryGetValue(req.key, out abDownloadOp))
            {
#if HUGULA_PROFILER_DEBUG
                Profiler.BeginSample(string.Format("LoadAssetBundleInternal ({0},{1},{2})", req.assetName, req.key, req.isShared));
#endif
                if (!UriGroup.CheckRequestCurrentIndexCrc(req)) //crc
                {
                    abDownloadOp       = new AssetBundleDownloadErrorOperation();
                    abDownloadOp.error = string.Format("assetbundle({0}) crc check wrong ", req.key);
                }
                else if (req.url.StartsWith(Common.HTTP_STRING))  //load assetbunlde
                {
                    abDownloadOp = AssetBundleDownloadFromWebOperation.Get();
                }
                else
                {
                    abDownloadOp = AssetBundleDownloadFromDiskOperation.Get();
                }
                abDownloadOp.SetRequest(req);
                downloadingBundles.Add(req.key, abDownloadOp);
                CacheData cached = null;
                CacheManager.CreateOrGetCache(req.keyHashCode, out cached);//cache data
                //load now
                if (bundleMax - inProgressBundleOperations.Count > 0)
                {
                    inProgressBundleOperations.Add(abDownloadOp);
                    abDownloadOp.BeginDownload();
                }
                else
                {
                    bundleQueue.Enqueue(abDownloadOp);
                }
#if HUGULA_LOADER_DEBUG
                HugulaDebug.FilterLogFormat(req.key, "<color=#10f010>1.2 LoadAssetBundleInternal Request(key={0},isShared={1},assetname={2},dependencies.count={4})keyHashCode{3}, frameCount{5}</color>", req.key, req.isShared, req.assetName, req.keyHashCode, req.dependencies == null ? 0 : req.dependencies.Length, Time.frameCount);
#endif

#if HUGULA_PROFILER_DEBUG
                Profiler.EndSample();
#endif
            }
            else if (req.isShared)
            {
                req.ReleaseToPool();
            }

            return(abDownloadOp);
        }