Beispiel #1
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();
                }
            }
        }
Beispiel #2
0
        //========================================
        //--------------- assetbundle asset logic--------------------
        //========================================

        /// <summary>
        /// Insert AssetBundleLoadAssetOperation to inProgressOperations list
        /// </summary>
        /// <param name="operation"></param>
        static void InsertAssetBundleLoadAssetOperation(AssetBundleDownloadOperation operation)
        {
            ResourcesLoadOperation rp = operation.next;

            while (rp != null)
            {
                inProgressOperations.Add(rp);
                rp = rp.next;
            }
        }
Beispiel #3
0
        /// <summary>
        /// finish asset or http request
        /// </summary>
        /// <param name="operation"></param>
        internal 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;
                SetCacheAsset(req);        // set asset cache
                DispatchAssetBundleLoadAssetOperation(req, isError);
                assetLoad.ReleaseToPool(); //relase AssetBundleLoadAssetOperation

                CheckAllComplete();        //check all complete
            }
            else if ((httpLoad = operation as HttpLoadOperation) != null)
            {
                isError = !string.IsNullOrEmpty(httpLoad.error);

                if (isError && CUtils.IsResolveHostError(httpLoad.error) && !CUtils.IsHttps(req.url))// http dns
                {
                    httpLoad.error = string.Format("dns resolve error url={0} ", req.url);
                    var httpDnsOp = HttpDnsResolve.Get();
                    httpDnsOp.SetRequest(req);
                    httpDnsOp.SetOriginalOperation(httpLoad);
                    inProgressOperations.Add(httpDnsOp);
                }
                else
                {
                    httpLoad.ReleaseToPool();

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

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

                    req.ReleaseToPool();
                }
            }
            else
            {
                operation.ReleaseToPool();
            }
        }
        public void AddNext(ResourcesLoadOperation assetOperation)
        {
            ResourcesLoadOperation n    = this;
            ResourcesLoadOperation next = this.next;

            while (next != null)
            {
                n    = next;
                next = n.next;
            }
            n.next = assetOperation;
        }
Beispiel #5
0
        static protected void LoadAssetInternalSimulation(CRequest req)
        {
            ResourcesLoadOperation op = null;

            if (LoaderType.Typeof_ABScene.Equals(req.assetType))
            {
                op = OperationPools <LoadLevelOperationSimulation> .Get();
            }
            else
            {
                op = OperationPools <LoadAssetOperationSimulation> .Get();
            }

            op.SetRequest(req);
            inProgressOperations.Add(op);
            op.Start();
        }
Beispiel #6
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();//check all complete
            }
            else if ((httpLoad = operation as HttpLoadOperation) != null)
            {
                isError = httpLoad.error != null;
                operation.ReleaseToPool();
                if (isError)
                {
                    req.DispatchEnd();
                }
                else
                {
                    req.DispatchComplete();
                }

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

                req.ReleaseToPool();
            }
        }
Beispiel #7
0
        /// <summary>
        /// finish asset or http request
        /// </summary>
        /// <param name="operation"></param>
        internal static void ProcessFinishedOperation(ResourcesLoadOperation operation)
        {
            HttpLoadOperation httpLoad;
            var req = operation.cRequest;

            operation.Done();

            if (operation is LoadAssetBundleInternalOperation)
            {
#if DEBUG
                Profiler.BeginSample("ProcessFinishedOperation AssetbundleDone " + req.assetName);
#endif
                CallOnAssetBundleComplete(req, ((LoadAssetBundleInternalOperation)operation).assetBundle);
                downloadingBundles.Remove(req.key);
                if (req.isShared)
                {
                    req.ReleaseToPool();
                }
                operation.ReleaseToPool();
                LoadingBundleQueue();
#if DEBUG
                Profiler.EndSample();
#endif
            }
            else if ((httpLoad = operation as HttpLoadOperation) != null)
            {
                bool isError = !string.IsNullOrEmpty(httpLoad.error);
                if (isError && CUtils.IsResolveHostError(httpLoad.error) && !CUtils.IsHttps(req.url))   // http dns
                {
                    // req.error = httpLoad.error;
                    Debug.LogFormat("dns resolve error url={0} ", req.url);
                    // httpLoad.error = string.Format ("dns resolve error url={0} ", req.url);
                    var httpDnsOp = OperationPools <HttpDnsResolve> .Get(); // HttpDnsResolve.Get();

                    httpDnsOp.SetRequest(req);
                    httpDnsOp.SetOriginalOperation(httpLoad);
                    inProgressOperations.Add(httpDnsOp);
                    httpDnsOp.Start();
                }
                else
                {
#if DEBUG
                    Profiler.BeginSample("ProcessFinishedOperation HttpDone " + req.url);
#endif
                    operation.ReleaseToPool();
                    try {
                        if (isError)
                        {
                            req.DispatchEnd();
                        }
                        else
                        {
                            req.DispatchComplete();
                        }
                    } catch (System.Exception e) {
                        Debug.LogError(e);
                    }

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

                    req.ReleaseToPool();
#if DEBUG
                    Profiler.EndSample();
#endif
                }
            }
            else
            {
#if DEBUG
                Profiler.BeginSample("ProcessFinishedOperation AssetDone " + req.assetName);
#endif
                loadingTasks.Remove(req);
                operation.ReleaseToPool();

                DispatchReqAssetOperation(req, req.error != null);
#if DEBUG
                Profiler.EndSample();
#endif
                CheckAllComplete();
            }
        }
 public virtual void Reset()
 {
     pool     = false;
     cRequest = null;
     next     = null;
 }
Beispiel #9
0
 public override void Reset()
 {
     base.Reset();
     this.originalOperation = null;
 }
Beispiel #10
0
 public void SetOriginalOperation(ResourcesLoadOperation originalOperation)
 {
     this.originalOperation = originalOperation;
 }