CheckDependenciesComplete() 공개 정적인 메소드

判断所有依赖项目是否加载完成
public static CheckDependenciesComplete ( CRequest req ) : bool
req CRequest
리턴 bool
예제 #1
0
        public bool Update()
        {
            if (!m_start)
            {
                Start();
            }

            if (m_abRequest == null)
            {
                return(false);
            }

            if (m_CancelDone)
            {
                return(false);
            }

            bool isdone = m_abRequest.isDone;

            if (isdone)
            {
                m_Done(m_abRequest.assetBundle);
            }

            if (!CacheManager.CheckDependenciesComplete(assetBundleName)) // && Time.frameCount - frameBegin >= timeOutFrame)
            {
                return(true);                                             //wait
            }
            return(!isdone);
        }
예제 #2
0
        bool m_Update()
        {
            if (!CacheManager.CheckDependenciesComplete(cRequest))
            {
                return(true);                                                    //wait
            }
            if (cRequest.error != null)
            {
                return(false);                        //assetbundle is error
            }
            if (m_Bundle == null)
            {
                m_Bundle = CacheManager.TryGetCache(cRequest.keyHashCode);
            }

            if (m_Bundle == null)
            {
                return(true);
            }

            if (m_Request != null)
            {
                return(!m_Request.isDone);
            }

            if (m_Bundle.isError || !m_Bundle.canUse)
            {
                cRequest.error = string.Format("load asset({0}) from bundle({1})  error", cRequest.assetName, cRequest.key);
                Debug.LogError(cRequest.error);
                return(false);
            }
            else
            {
                string assetName = cRequest.assetName;
                var    typ       = cRequest.assetType;
                bool   isLoadAll = LoaderType.Typeof_ABAllAssets.Equals(typ);
                if (isLoadAll)
                {
                    m_Request = m_Bundle.assetBundle.LoadAllAssetsAsync();
                }
                else
                {
                    m_Request = m_Bundle.assetBundle.LoadAssetAsync(cRequest.assetName, typ);
                }

#if HUGULA_LOADER_DEBUG
                HugulaDebug.FilterLogFormat(cRequest.key, " <color=#15A0A1> 1.2 Asset  Request(assetName={0}) is done={1} key={2},frame={3} </color>", cRequest.assetName, m_Request.isDone, cRequest.key, Time.frameCount);
#endif
                return(!m_Request.isDone);
            }
        }
예제 #3
0
        bool m_Update()
        {
            if (m_abRequest == null)
            {
                return(false);
            }

            bool isdone = !m_abRequest.isDone;

            if (!CacheManager.CheckDependenciesComplete(cRequest)) // && Time.frameCount - frameBegin >= timeOutFrame)
            {
                return(true);                                      //wait
            }
#if HUGULA_LOADER_DEBUG
            HugulaDebug.FilterLogFormat(cRequest.key, " <color=#15A0A1> 1 AssetBundle update Request(assetName={0}) key={1},isdone = {2},m_abRequest={3},frame={4} </color>", cRequest.assetName, cRequest.key, isdone, m_abRequest, Time.frameCount);
#endif
            return(isdone);
        }
예제 #4
0
        // Update is called once per frame
        void Update()
        {
            for (int i = 0; i < freeLoader.Count;)
            {
                CCar load = freeLoader[i];
                if (load.enabled)
                {
                    load.Update();
                }

                if (load.isFree)
                {
                    freeLoader.RemoveAt(i);
                    ReleaseCCar(load);  //放回对象池
                }
                else
                {
                    i++;
                }
            }

            //1 load assetbunlde
            for (int i = 0; i < loaderPool.Count; i++)
            {
                CCar load = loaderPool[i];
                if (load.isFree && realyLoadingQueue.Count > 0)
                {
                    var req = realyLoadingQueue.Dequeue();
                    if (CheckLoadedAssetBundle(req))
                    {
                        CheckLoadAssetAsync(req);
                    }
                    else if (CheckLoadingAssetBundle(req))
                    {
                        AddReqToQueue(req);
                    }
                    else
                    {
                        downloadings[req.udKey] = load;
                        load.BeginLoad(req);
                    }
                }
                if (load.enabled)
                {
                    load.Update();
                }
            }
#if UNITY_EDITOR
            loadingAssetBundleQueueCount = loadingAssetBundleQueue.Count;
            loadingAssetQueueCount       = loadingAssetQueue.Count;
            DebugInfo = "";
#endif
            //2 wait dependencies set asset
            for (int i = 0; i < loadingAssetBundleQueue.Count;)
            {
                var item = loadingAssetBundleQueue[i];
                if (CacheManager.CheckDependenciesComplete(item))   //判断依赖项目是否加载完成
                {
                    if (CacheManager.SetRequestDataFromCache(item)) //设置缓存数据。
                    {
                        loadingAssetQueue.Add(item);                //加载资源
                    }
                    else
                    {
                        loadedAssetQueue.Enqueue(item);
#if HUGULA_LOADER_DEBUG
                        Debug.LogFormat("<color=red> 2.2 SetRequestDataFromCache false Req(assetname={0},url={1}) frame={2}loadingAssetBundleQueue.Count={3} </color>", item.assetName, item.url, Time.frameCount, loadingAssetBundleQueue.Count);
#endif
                    }
                    // if (item.assetBundleRequest != null)
                    //  CacheManager.AddLock (item.keyHashCode);//异步需要锁定
                    loadingAssetBundleQueue.RemoveAt(i);
#if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" 2.3 <color=#15C132>DependenciesComplete Req(assetname={0},url={1},async={2}) frameCount{3},loadingAssetBundleQueue.Count={4}</color>", item.assetName, item.url, item.async, Time.frameCount, loadingAssetBundleQueue.Count);
#endif
                }
                else
                {
                    i++;
#if UNITY_EDITOR
                    DebugInfo += string.Format(" -2.3CheckDependenciesComplete Req(assetname={0},url={1}) frameCount{2},loadingAssetBundleQueue.Count={3}</color>", item.assetName, item.url, Time.frameCount, loadingAssetBundleQueue.Count);
#endif
#if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" -2.3 <color=#15C132>CheckDependenciesComplete Req(assetname={0},url={1}) frameCount{2},loadingAssetBundleQueue.Count={3}</color>", item.assetName, item.url, Time.frameCount, loadingAssetBundleQueue.Count);
#endif
                }
            }

            //3 load asset
            for (int i = 0; i < loadingAssetQueue.Count; i++)
            {
                var item = loadingAssetQueue[i];
#if HUGULA_LOADER_DEBUG
                Debug.LogFormat(" 3.2.-1 <color=#A9C115> Req(assetname={0},url={1}) loadingAssetQueue.Count={2} frameCount{3} </color>", item.assetName, item.url, loadingAssetQueue.Count, Time.frameCount);
#endif
                if (item.assetBundleRequest != null && item.assetBundleRequest.isDone) //如果加载完成
                {
#if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" 3.2.0 <color=#A9C115>set Req(assetname={0},url={1}).data asnyc Count{2} frameCount{3} </color>", item.assetName, item.url, loadingAssetQueue.Count, Time.frameCount);
#endif
                    if (item.assetBundleRequest is AssetBundleRequest)
                    {
                        if (CacheManager.Typeof_ABAllAssets.Equals(item.assetType))
                        {
                            item.data = ((AssetBundleRequest)item.assetBundleRequest).allAssets;  //赋值
                        }
                        else
                        {
                            item.data = ((AssetBundleRequest)item.assetBundleRequest).asset;  //赋值
                        }
                    }
                    else
                    {
                        item.data = item.assetBundleRequest;
                    }
#if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" 3.2.1 <color=#A9C115>set Req(assetname={0},url={1} data{2}) end </color>", item.assetName, item.url, item.data);
#endif
                    loadedAssetQueue.Enqueue(item);
                    loadingAssetQueue.RemoveAt(i);
                }
                else if (item.assetBundleRequest == null)   //非异步
                {
                    loadedAssetQueue.Enqueue(item);
                    loadingAssetQueue.RemoveAt(i);
#if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" 3.2 <color=#A9C115>set Req(assetname={0},url={1}).data Async  Count{2} frameCount{3}</color>", item.assetName, item.url, loadingAssetQueue.Count, Time.frameCount);
#endif
                }
                else
                {
                    i++;
                }
            }

            //4 complete asset
            while (loadedAssetQueue.Count > 0)
            {
                LoadAssetComplate(loadedAssetQueue.Dequeue());
            }

            //group check
            for (int i = 0; i < allGroupRequestRecord.Count;)
            {
                var group = allGroupRequestRecord[i];
                group.Progress();
                if (group.Count > 0)
                {
                    i++;
                }
                else
                {
                    var act = group.onGroupComplate;
                    GroupRequestRecord.Release(group);
                    allGroupRequestRecord.RemoveAt(i);
                    if (act != null)
                    {
                        act(group);
                    }
                }
            }
        }
예제 #5
0
        // Returns true if more Update calls are required.
        private bool _Update()
        {
            url = cRequest.url;

            if (m_Request != null)   // wait asset complete
            // if (cRequest.OnComplete != null) return !_IsDone (); // wait asset complete
            {
                return(!_IsDone());
            }

            CacheData bundle = CacheManager.TryGetCache(cRequest.keyHashCode);

#if HUGULA_LOADER_DEBUG
            HugulaDebug.FilterLogFormat(cRequest.key, "<color=#15A0A1>2.1.0 AssetBundleLoadAssetOperationFull.update  loadasset Request(url={0},assetname={1},CheckDependenciesComplete={3})bundle={2},asyn={4},frameCount={5}</color>", cRequest.url, cRequest.assetName, bundle, CacheManager.CheckDependenciesComplete(cRequest), cRequest.async, Time.frameCount);
#endif
            if (bundle != null && bundle.isDone && CacheManager.CheckDependenciesComplete(cRequest))
            {
                if (bundle.isError || !bundle.canUse)
                {
                    error = string.Format("load asset({0}) from bundle({1})  error", cRequest.assetName, cRequest.key);
                    return(false);
                }
                else
                {
#if HUGULA_LOADER_DEBUG
                    assetName = cRequest.assetName;
                    HugulaDebug.FilterLogFormat(cRequest.key, "<color=#15A0A1>2.1.0.1 AssetBundleLoadAssetOperationFull.update  loadasset Request(url={0},assetname={1},dependencies.count={3})keyHashCode{2},asyn={4},frameCount={5}</color>", cRequest.url, cRequest.assetName, cRequest.keyHashCode, cRequest.dependencies == null ? 0 : cRequest.dependencies.Length, cRequest.async, Time.frameCount);
#endif
                    var typ = cRequest.assetType;
                    isLoadAll = LoaderType.Typeof_ABAllAssets.Equals(typ);

                    if (cRequest.async)
                    {
                        if (isLoadAll)
                        {
                            m_Request = bundle.assetBundle.LoadAllAssetsAsync();
                        }
                        else
                        {
                            m_Request = bundle.assetBundle.LoadAssetAsync(cRequest.assetName, typ);
                        }
                    }
                    else
                    {
                        if (isLoadAll)
                        {
                            m_Data = bundle.assetBundle.LoadAllAssets();
                        }
                        else
                        {
                            m_Data = bundle.assetBundle.LoadAsset(cRequest.assetName, typ);
                        }

                        if (m_Data == null)
                        {
                            error = string.Format("load asset({0}) from {1}  error", cRequest.assetName, cRequest.key);
                        }
                    }
#if HUGULA_LOADER_DEBUG
                    HugulaDebug.FilterLogFormat(cRequest.key, "<color=#15A0A1>2.1.0.2 AssetBundleLoadAssetOperationFull.update isdone Request(url={0},assetname={1}),m_Request={2},m_Data={3},error={4},frameCount={5}</color>", cRequest.url, cRequest.assetName, m_Request, m_Data, error, Time.frameCount);
#endif
                    return(!_IsDone());
                } // check bundle
            }
            else
            {
                return(true);
            }
        }
예제 #6
0
        public bool Update()
        {
            if (m_Request != null)
            {
                CRequest.SetProgress(request, m_Request.progress);
                if (!allowSceneActivation && LoaderType.Typeof_ABScene.Equals(request.assetType) && m_Request.progress >= 0.9f)//加载场景的时候如果allowSceneActivation = false 只能通过progress判断完成
                {
                    return(false);
                }
                else
                {
                    return(!m_Request.isDone);
                }
            }

#if UNITY_EDITOR
            if (m_isDone)
            {
                return(false);          //only for editor 模拟模式使用
            }
#endif
            if (m_Bundle == null)
            {
                m_Bundle = CacheManager.TryGetCache(request.assetBundleName);
            }

            if (m_Bundle == null || !m_Bundle.isDone || !CacheManager.CheckDependenciesComplete(request.assetBundleName))
            {
                return(true);     //wait bundle done
            }
            if (!m_Bundle.canUse) //ab失效
            {
                CRequest.SetError(request, string.Format("load asset({0}) from bundle({1}).canUse = false  error", request.assetName, request.assetBundleName));
                Debug.LogError(request.error);
                return(false);
            }
            else
            {
                string assetName = request.assetName;
                var    typ       = request.assetType;

                if (LoaderType.Typeof_ABScene.Equals(typ))
                {
                    m_Request = SceneManager.LoadSceneAsync(assetName, loadSceneMode);
                    m_Request.allowSceneActivation = allowSceneActivation;
                    CRequest.SetData(request, m_Request);                              //加载场景比较特殊 提前返回AsyncOperation对象方便操作
                    CacheManager.AddScene(request.assetName, request.assetBundleName); //缓存场景
                    if (!allowSceneActivation)
                    {
                        CacheManager.AddLoadingScene(request.assetName, m_Request);
                    }
                }
                else if (subAssets)
                {
                    m_Request = m_Bundle.assetBundle.LoadAssetWithSubAssetsAsync(assetName, typ);
                }
                else
                {
                    m_Request = m_Bundle.assetBundle.LoadAssetAsync(assetName, typ);
                }
                // #if HUGULA_LOADER_DEBUG
                //                 // HugulaDebug.FilterLogFormat (cRequest.key, " <color=#15A0A1> 1.2 Asset  Request(assetName={0}) is done={1} key={2},frame={3} </color>", cRequest.assetName, m_Request.isDone, cRequest.key, Time.frameCount);
                // #endif
                // GS_GameLog.LogFormat("LoadAssetAsync({0},{1}) m_Request.isDone={2}", assetName, typ, m_Request.isDone);
                CRequest.SetProgress(request, m_Request.progress);

                return(!m_Request.isDone);
            }
        }
예제 #7
0
        // Update is called once per frame
        void Update()
        {
            //加载
            for (int i = 0; i < loaderPool.Count; i++)
            {
                CCar load = loaderPool[i];
                if (load.isFree && realyLoadingQueue.Count > 0)
                {
                    var req = realyLoadingQueue.Dequeue();
                    if (!CheckLoadAssetBundle(req))
                    {
                        downloadings[req.udKey] = true;
                        load.BeginLoad(req);
                    }
                }
                if (load.enabled)
                {
                    load.Update();
                }
            }

            for (int i = 0; i < freeLoader.Count;)
            {
                CCar load = freeLoader [i];
                if (load.enabled)
                {
                    load.Update();
                }

                if (load.isFree)
                {
                                        #if HUGULA_LOADER_DEBUG
                    if (load.req != null)
                    {
                        Debug.LogFormat(" 1. a <color=yellow>freeLoader is free Req(assetname={0},url={1}) frameCount{2}</color>", load.req.assetName, load.req.url, Time.frameCount);
                    }
                    else
                    {
                        Debug.LogFormat(" 1. a <color=yellow>freeLoader is free Req(assetname={0},url={1}) frameCount{2}</color>", load, load, Time.frameCount);
                    }
                                        #endif
                    freeLoader.RemoveAt(i);
                    ReleaseCCar(load);                      //放回对象池
                }
                else
                {
                    i++;
                }
            }

            //ab
            for (int i = 0; i < loadingAssetBundleQueue.Count;)
            {
                var item = loadingAssetBundleQueue[i];
                if (CacheManager.CheckDependenciesComplete(item))                   //判断依赖项目是否加载完成
                {
                    CacheManager.SetRequestDataFromCache(item);                     //设置缓存数据。
                    loadingAssetQueue.Add(item);
                    if (item.assetBundleRequest != null)
                    {
                        CacheManager.AddLock(item.keyHashCode);                         //异步需要锁定
                    }
                    loadingAssetBundleQueue.RemoveAt(i);
                                        #if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" 4. <color=yellow>DependenciesComplete Req(assetname={0},url={1}) frameCount{2}</color>", item.assetName, item.url, Time.frameCount);
                                        #endif
                }
                else
                {
                    i++;
                                        #if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" -4. <color=yellow>CheckDependenciesComplete Req(assetname={0},url={1}) frameCount{2}</color>", item.assetName, item.url, Time.frameCount);
                                        #endif
                }
            }

            //asset
            for (int i = 0; i < loadingAssetQueue.Count; i++)
            {
                var item = loadingAssetQueue[i];
                if (item.assetBundleRequest != null && item.assetBundleRequest.isDone) //如果加载完成
                {
                    if (item.assetBundleRequest is AssetBundleRequest)
                    {
                        item.data = ((AssetBundleRequest)item.assetBundleRequest).asset;//赋值
                    }
                    else
                    {
                        item.data = item.assetBundleRequest;
                    }
                                        #if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" 5. <color=yellow>set Req(assetname={0},url={1}).data asnyc Count{2} frameCount{3} </color>", item.assetName, item.url, loadingAssetQueue.Count, Time.frameCount);
                                        #endif
                    loadedAssetQueue.Enqueue(item);
                    loadingAssetQueue.RemoveAt(i);
                }
                else if (item.assetBundleRequest == null) //非异步
                {
                    loadedAssetQueue.Enqueue(item);
                    loadingAssetQueue.RemoveAt(i);
                                        #if HUGULA_LOADER_DEBUG
                    Debug.LogFormat(" 5. <color=yellow>set Req(assetname={0},url={1}).data  Count{2} frameCount{3}</color>", item.assetName, item.url, loadingAssetQueue.Count, Time.frameCount);
                                        #endif
                }
                else
                {
                    i++;
                }
            }

            while (loadedAssetQueue.Count > 0)
            {
                LoadAssetComplate(loadedAssetQueue.Dequeue());
            }

            //组进度条
            for (int i = 0; i < allGroupRequestRecord.Count;)
            {
                var group = allGroupRequestRecord [i];
                group.Progress();
                if (group.Count > 0)
                {
                    i++;
                }
                else
                {
                    var act = group.onGroupComplate;
                    GroupRequestRecordPool.Release(group);
                    allGroupRequestRecord.RemoveAt(i);
                    if (act != null)
                    {
                        act(group);
                    }
                }
            }
        }