示例#1
0
        /// <summary>
        /// Load AssetBundle Error
        /// </summary>
        /// <param name="req">Req.</param>
        static void LoadError(CCar cloader, CRequest req)
        {
            downloadings.Remove(req.udKey);

#if HUGULA_LOADER_DEBUG
            Debug.LogFormat(" 1.3 <color=red>CResLoader.LoadError Request(assetName={0}, url={1},isShared={2} req.index={3},req.uris.count={4})</color>", req.assetName, req.url, req.isShared, req.index, req.uris == null ? 0 : req.uris.count);
#endif
            if (req.uris != null && req.index < req.uris.count - 1 && UriGroup.CheckAndSetNextUriGroup(req))  // CUtils.SetRequestUri(req, req.index))
            {
                QueueOrLoad(req);
            }
            else
            {
                if (!req.isShared)
                {
                    currentLoaded++;
                }
                CallbackError(req);
                if (!req.isShared && !string.IsNullOrEmpty(req.assetBundleName) && _instance != null && _instance.OnAssetBundleErr != null)
                {
                    _instance.OnAssetBundleErr(req);
                }
                BeginQueue();
                CheckAllComplete();
            }
        }
示例#2
0
        /// <summary>
        /// finish asset or http request
        /// </summary>
        /// <param name="operation"></param>
        static void ProcessFinishedOperation(ResourcesLoadOperation operation)
        {
            var  req     = operation.cRequest;
            bool isError = false;
            AssetBundleLoadAssetOperation assetLoad = operation as AssetBundleLoadAssetOperation;
            HttpLoadOperation             httpLoad;

            if (assetLoad != null)
            {
                loadingTasks.Remove(req);
                isError = assetLoad.error != null;
                operation.ReleaseToPool(); //relase AssetBundleLoadAssetOperation
                SetCacheAsset(req);        // set asset cache
                DispatchAssetBundleLoadAssetOperation(req, isError);

                //等两帧再CheckAllComplete
                allCompleteCheckCount = 0.5f;
                //CheckAllComplete();//check all complete
            }
            else if ((httpLoad = operation as HttpLoadOperation) != null)
            {
                isError = !string.IsNullOrEmpty(httpLoad.error);

                if (isError && UriGroup.CheckAndSetNextUriGroup(req)) //
                {
#if HUGULA_LOADER_DEBUG
                    HugulaDebug.FilterLogFormat(req.key, "<color=#10f010>1.9  ProcessFinishedOperation re Loaded Request(url={0},assetname={1},dependencies.count={3},keyHashCode{2}),isError={4} frameCount{5}</color>", req.url, req.assetName, req.keyHashCode, req.dependencies == null ? 0 : req.dependencies.Length, isError, Time.frameCount);
#endif
                    // Debug.LogFormat(" re try {0};",req.url);
                    inProgressOperations.Add(httpLoad);
                    httpLoad.Reset();
                    httpLoad.SetRequest(req);
                    httpLoad.BeginDownload(); //retry
                }
                else
                {
                    operation.ReleaseToPool();

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

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

                    req.ReleaseToPool();
                }
            }
        }
示例#3
0
        /// <summary>
        /// finish assetbundle
        /// </summary>
        /// <param name="operation"></param>
        static void ProcessFinishedBundleOperation(AssetBundleDownloadOperation operation)
        {
#if HUGULA_PROFILER_DEBUG
            Profiler.BeginSample(string.Format("ResourcesLoader.ProcessFinishedBundleOperation CRequest({0},shared={1})", operation.cRequest.assetName, operation.cRequest.isShared));
#endif
            var  req     = operation.cRequest;
            bool isError = operation.assetBundle == null;
            var  ab      = operation.assetBundle;
            AssetBundleDownloadOperation download = operation;

            if (isError && UriGroup.CheckAndSetNextUriGroup(req))
            {
#if HUGULA_LOADER_DEBUG
                HugulaDebug.FilterLogFormat(req.key, "<color=#10f010>1.9  ProcessFinishedBundleOperation AssetBundle re Loaded Request(url={0},assetname={1},dependencies.count={3},keyHashCode{2}),isError={4} frameCount{5}</color>", req.url, req.assetName, req.keyHashCode, req.dependencies == null ? 0 : req.dependencies.Length, isError, Time.frameCount);
#endif
                //loop load a assetbundle maybe cause a crash :  signal 6 (SIGABRT), code -6 (?), fault addr --------
                inProgressBundleOperations.Add(download);
                download.Reset();
                download.SetRequest(req);
                download.BeginDownload(); //retry
            }
            else
            {
                if (!isError)
                {
                    CacheManager.AddSourceCacheDataFromWWW(ab, req);
                }
                else
                {
#if UNITY_EDITOR
                    Debug.LogWarning(operation.error);
#endif
                    CacheManager.AddErrorSourceCacheDataFromReq(req);
                }
#if HUGULA_LOADER_DEBUG
                HugulaDebug.FilterLogFormat(req.key, "<color=#10f010>1.9  ProcessFinishedBundleOperation AssetBundle Loaded Request(url={0},assetname={1},dependencies.count={3},keyHashCode{2}),isError={4} frameCount{5}</color>", req.url, req.assetName, req.keyHashCode, req.dependencies == null ? 0 : req.dependencies.Length, isError, Time.frameCount);
#endif

                //begin load asset
                InsertAssetBundleLoadAssetOperation(download);

                downloadingBundles.Remove(req.key);
                download.ReleaseToPool();

                if (isError)
                {
                    CallOnAssetBundleErr(req);
                }
                else
                {
                    CallOnAssetBundleComplete(req, ab);
                }

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