示例#1
0
        protected static void LoadAssetComplate(CRequest req)
        {
                        #if HUGULA_LOADER_DEBUG
            Debug.LogFormat(" 6. <color=yellow>LoadAssetComplate Req(assetname={0},url={1}) frameCount{2}</color>", req.assetName, req.url, Time.frameCount);
                        #endif
            if (req.isShared)
            {
                CountMananger.Add(req.keyHashCode);
                CountMananger.AddDependencies(req.keyHashCode);
                if (_instance && _instance.OnSharedComplete != null)
                {
                    _instance.OnSharedComplete(req);
                }

                CacheManager.SetAssetLoaded(req.keyHashCode);
                if (req.pool)
                {
                    LRequestPool.Release(req);
                }
            }
            else
            {
                if (req.assetBundleRequest != null)
                {
                    CacheManager.RemoveLock(req.keyHashCode);
                }
                req.DispatchComplete();
                PopGroup(req);
            }
            BeginQueue();
            CheckAllComplete();
        }
示例#2
0
        private static void DispatchReqComplete(CRequest reqitem)
        {
            if (reqitem.isShared)
            {
                CountMananger.Add(reqitem.keyHashCode);
                CountMananger.AddDependencies(reqitem.keyHashCode);
                if (_instance && _instance.OnSharedComplete != null)
                {
                    _instance.OnSharedComplete(reqitem);
                }

                CacheManager.SetAssetLoaded(reqitem.keyHashCode);
                if (reqitem.pool)
                {
                    LRequestPool.Release(reqitem);
                }
            }
            else
            {
                if (reqitem.assetBundleRequest != null)
                {
                    CacheManager.RemoveLock(reqitem.keyHashCode);
                }
                reqitem.DispatchComplete();
                PopGroup(reqitem);
            }
        }
示例#3
0
        /// <summary>
        /// stop the url.
        /// </summary>
        /// <param name="req">Req.</param>
        /// <param name="group">Group.</param>
        public void StopURL(string url)
        {
            LRequest reqUrl = LRequestPool.Get();

            reqUrl.relativeUrl = url;
            StopReq(reqUrl);
            LRequestPool.Release(reqUrl);
        }
示例#4
0
        /// <summary>
        /// 加载依赖项目
        /// </summary>
        /// <param name="req"></param>
        static protected int[] LoadDependencies(CRequest req)
        {
            string[] deps = assetBundleManifest.GetAllDependencies(req.assetBundleName);

            if (deps.Length == 0)
            {
                return(null);
            }
            string   dep_url;
            string   depAbName = "";
            CRequest item;

            int[] hashs = new int[deps.Length];
            int   keyhash;

            for (int i = 0; i < deps.Length; i++)
            {
                depAbName = deps [i];
                dep_url   = RemapVariantName(depAbName);
                keyhash   = LuaHelper.StringToHash(dep_url);
                hashs[i]  = keyhash;
                if (CacheManager.Contains(keyhash))
                {
                    CountMananger.Add(keyhash);                      //引用数量加1
                }
                else
                {
                    item             = LRequestPool.Get();         //new CRequest(dep_url);
                    item.relativeUrl = dep_url;
                    item.isShared    = true;
                    item.async       = false;
                    //依赖项目
                    string[] depds = assetBundleManifest.GetAllDependencies(item.assetBundleName);
                    if (depds.Length > 0)
                    {
                        int[] hash1s = new int[depds.Length];
                        for (int i1 = 0; i1 < depds.Length; i1++)
                        {
                            depAbName  = depds [i1];
                            dep_url    = RemapVariantName(depAbName);
                            keyhash    = LuaHelper.StringToHash(dep_url);
                            hash1s[i1] = keyhash;
                        }
                        item.allDependencies = hash1s;
                    }
                                        #if HUGULA_LOADER_DEBUG
                    Debug.LogFormat("<color=yellow> Req(assetname={0}) /r/n Begin LoadDependencies Req(assetname={1},url={2}) frameCount{3}</color>", req.assetBundleName, item.assetName, item.url, Time.frameCount);
                                        #endif
                    item.isNormal = req.isNormal;
                    item.uris     = req.uris;
                    AddReqToQueue(item);
                }
            }

            return(hashs);
        }
示例#5
0
        static void PopGroup(CRequest req)
        {
            GroupRequestRecord group;

            if (currGroupRequestsRef.TryGetValue(req, out group))
            {
                currGroupRequestsRef.Remove(req);
                group.Complete(req);
            }

            if (req.pool)
            {
                LRequestPool.Release(req);
            }
        }
示例#6
0
        protected static void CallbackError(CRequest creq)
        {
#if HUGULA_LOADER_DEBUG
            Debug.LogFormat("4 <color=green>CallbackError DispatchEnd Req(assetname={0},url={1}) frame={2} </color>", creq.assetName, creq.url, Time.frameCount);
#endif
            List <CRequest> callbacklist = null;// requestCallBackList[creq.udKey];
            string          udkey        = creq.udKey;
            // load
            if (creq.isShared)
            {
                if (_instance.OnSharedErr != null)
                {
                    _instance.OnSharedErr(creq);
                }

                if (creq.pool)
                {
                    LRequestPool.Release(creq);
                }
            }
            else if (requestCallBackList.TryGetValue(udkey, out callbacklist))
            {
                requestCallBackList.Remove(udkey);
                int      count = callbacklist.Count;
                CRequest reqitem;
                for (int i = 0; i < count; i++)
                {
                    reqitem = callbacklist [i];
                    reqitem.DispatchEnd();
                    PopGroup(reqitem);
                }
                ListPool <CRequest> .Release(callbacklist);
            }
            else
            {
                creq.DispatchEnd();
                PopGroup(creq);
            }

            CheckAllComplete();
        }
示例#7
0
文件: CCar.cs 项目: jie007/hugula
 public void StopLoad()
 {
     if (isFree && !enabled)
     {
         enabled = false;
         isFree  = true;
         if (www != null)
         {
             www.Dispose();
             www = null;
         }
         if (abRequest != null)
         {
             abRequest = null;
         }
         if (this.req != null && req.pool)
         {
             LRequestPool.Release(req);
         }
         this._req = null;
     }
 }
示例#8
0
        /// <summary>
        /// 加载依赖项目
        /// </summary>
        /// <param name="req"></param>
        static protected int[] LoadDependencies(CRequest req)
        {
            string[] deps = assetBundleManifest.GetAllDependencies(req.assetBundleName);

            if (deps.Length == 0)
            {
                return(null);
            }
            string   dep_url;
            string   depAbName = "";
            CRequest item;

            int[] hashs = new int[deps.Length];
            int   keyhash;

            for (int i = 0; i < deps.Length; i++)
            {
                depAbName = deps [i];
                if (string.IsNullOrEmpty(depAbName)) // Dependency assetbundle name is empty  unity bug?
                {
                    #if UNITY_EDITOR
                    Debug.LogWarningFormat("the request({0},{1}) Dependencies {2} is empty ", req.assetName, req.url, i);
                    #endif
                    hashs[i] = 0;
                    continue;
                }
                dep_url  = RemapVariantName(depAbName);
                keyhash  = LuaHelper.StringToHash(dep_url);
                hashs[i] = keyhash;
                CacheData sharedCD = CacheManager.GetCache(keyhash);
                if (sharedCD != null)
                {
                    CountMananger.Add(keyhash);                      //引用数量加1
                    if (!sharedCD.isAssetLoaded)
                    {
                        item               = LRequestPool.Get(); //new CRequest(dep_url);
                        item.relativeUrl   = dep_url;
                        item.isShared      = true;
                        item.async         = false;
                        item.isAssetBundle = true;

                        CacheManager.SetRequestDataFromCache(req);
                        if (_instance && _instance.OnSharedComplete != null)
                        {
                            _instance.OnSharedComplete(item);
                        }

                        LRequestPool.Release(item);
                    }
            #if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" 0.3 <color=#153AC1>Request(assetName={0}, url={1},isShared={2}) Dependencies  CacheManager.Contains(url={3},sharedCD.isAssetLoaded={4}) </color>", req.assetName, req.url, req.isShared, dep_url, sharedCD.isAssetLoaded);
                        #endif
                }
                else
                {
                    item               = LRequestPool.Get();       //new CRequest(dep_url);
                    item.relativeUrl   = dep_url;
                    item.isShared      = true;
                    item.async         = false;
                    item.isAssetBundle = true;
                    //依赖项目
                    string[] depds = assetBundleManifest.GetAllDependencies(item.assetBundleName);
                    if (depds.Length > 0)
                    {
                        int[] hash1s = new int[depds.Length];
                        for (int i1 = 0; i1 < depds.Length; i1++)
                        {
                            depAbName  = depds [i1];
                            dep_url    = RemapVariantName(depAbName);
                            keyhash    = LuaHelper.StringToHash(dep_url);
                            hash1s[i1] = keyhash;
                        }
                        item.allDependencies = hash1s;
                    }
                                        #if HUGULA_LOADER_DEBUG
                    Debug.LogFormat("<color=#153AC1>0.5  Request(assetname={0}) Begin Load Dependencies Req(assetname={1},url={2}) frameCount{3}</color>", req.assetName, item.assetName, item.url, Time.frameCount);
                                        #endif
                    item.isNormal = false;
                    item.priority = req.priority;
                    item.uris     = req.uris;
                    AddReqToQueue(item);
                }
            }

            return(hashs);
        }