Beispiel #1
0
        /// <summary>
        /// LoadAsset
        /// </summary>
        /// <param name="req"></param>
        /// <param name="coroutine"></param>
        /// <returns></returns>
        static public AssetBundleLoadAssetOperation LoadAsset(CRequest req, bool coroutine = false)
        {
            AssetBundleLoadAssetOperation op = null;
            var groupQueue = BundleGroundQueue.Get();

            groupQueue.priority = req.priority;
            groupQueue.Enqueue(req);
            if (coroutine)
            {
#if UNITY_EDITOR
                if (ManifestManager.SimulateAssetBundleInEditor)
                {
                    op = new AssetBundleLoadAssetOperationSimulation();
                }
                else
                {
                    op = new AssetBundleLoadAssetOperationFull();
                }
#else
                op = new AssetBundleLoadAssetOperationFull();
#endif
                op.SetRequest(req);
                req.assetOperation = op;
            }
            LoadGroupAsset(groupQueue);
            return(op);
        }
Beispiel #2
0
        /// <summary>
        /// check the queue and load assetbundle and asset
        /// </summary>
        static protected bool LoadingQueue()
        {
            if (inProgressBundleOperations.Count > 0)
            {
                return(false);                                      //wait bundle load
            }
            LinkedListNode <BundleGroundQueue> fristNode = bundleGroundQueue.First;

            while (fristNode != null && maxLoading - loadingTasks.Count > 0)
            {
                BundleGroundQueue value = fristNode.Value;
                if (value.Count > 0)
                {
                    var req = value.Dequeue();
#if HUGULA_LOADER_DEBUG
                    HugulaDebug.FilterLogFormat("LoadingQueue", "<color=#05AA01>0.1 LoadAssetBundle Request(url={0},assetname={1},dependencies.count={3})keyHashCode{2}, frameCount{4}</color>", req.url, req.assetName, req.keyHashCode, req.dependencies == null ? 0 : req.dependencies.Length, Time.frameCount);
#endif
                    LoadAssetBundle(req);
                }
                else
                {
                    fristNode = fristNode.Next;
                    bundleGroundQueue.Remove(value);
                }

                var ts = System.DateTime.Now - frameBegin;
                if (ts.TotalMilliseconds > BundleLoadBreakMilliSeconds)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// LoadAsset
        /// </summary>
        /// <param name="req"></param>
        /// <param name="coroutine"></param>
        /// <returns></returns>
        static public AssetBundleLoadAssetOperation LoadAsset(CRequest req, bool coroutine = false)
        {
            AssetBundleLoadAssetOperation op = null;

            if (coroutine)
            {
#if UNITY_EDITOR
                if (ManifestManager.SimulateAssetBundleInEditor)
                {
                    op = new AssetBundleLoadAssetOperationSimulation();
                }
                else
                {
                    op = new AssetBundleLoadAssetOperationFull();
                }
#else
                op = new AssetBundleLoadAssetOperationFull();
#endif
                op.SetRequest(req);
                req.assetOperation = op;
                op.Update();
            }

            var groupQueue = BundleGroundQueue.Get();
            groupQueue.priority = req.priority;
            groupQueue.Enqueue(req);
#if HUGULA_LOADER_DEBUG
            HugulaDebug.FilterLogFormat(req.key, "<color=#15A0A1>0.0.1  before LoadGroupAsset, ResourcesLoader.LoadAsset(Request(url={0},assetname={1},keyhash={2}),coroutine={3}),assetOperation={4},frameCount={5}</color>", req.url, req.assetName, req.keyHashCode, coroutine, op, Time.frameCount);
#endif

            LoadGroupAsset(groupQueue);
            return(op);
        }
Beispiel #4
0
 /// <summary>
 /// load group request
 /// </summary>
 /// <param name="bGroup"></param>
 static public void LoadGroupAsset(BundleGroundQueue bGroup)
 {
     while (bGroup != null && bGroup.Count > 0)
     {
         var req = bGroup.Dequeue();
         LoadAsset(req);
     }
 }
Beispiel #5
0
        /// <summary>
        /// load group request
        /// </summary>
        /// <param name="bGroup"></param>
        static public void LoadGroupAsset(BundleGroundQueue bGroup)
        {
            if (bGroup.Count == 0)
            {
                Debug.LogWarning("LoadGroupAsset group.count ==0");
                if (bGroup.onComplete != null)
                {
                    bGroup.onComplete(false);
                }
                return;
            }
#if HUGULA_LOADER_DEBUG
            HugulaDebug.FilterLogFormat("LoadGroupAsset", "<color=#05AA01>0.0 Append LoadGroupAsset  BundleGroundQueue(Count={0}priority={1}) frameCount{2}</color>", bGroup.Count, bGroup.priority, Time.frameCount);
#endif
            bool flag     = false;
            int  priority = bGroup.priority;
            for (LinkedListNode <BundleGroundQueue> fristNode = bundleGroundQueue.First; fristNode != null; fristNode = fristNode.Next)
            {
                if (fristNode.Value.priority == priority)
                {
#if HUGULA_LOADER_DEBUG
                    HugulaDebug.FilterLogFormat("LoadGroupAsset", "<color=#05AA01>0.0 LoadGroupAsset AddAfter BundleGroundQueue(Count={0}priority={1}) frameCount{2}</color>", bGroup.Count, bGroup.priority, Time.frameCount);
#endif
                    bundleGroundQueue.AddAfter(fristNode, bGroup);
                    flag = true;
                    break;
                }
                if (fristNode.Value.priority < priority)
                {
#if HUGULA_LOADER_DEBUG
                    HugulaDebug.FilterLogFormat("LoadGroupAsset", "<color=#05AA01>0.0 LoadGroupAsset AddBefore BundleGroundQueue(Count={0}priority={1}) frameCount{2}</color>", bGroup.Count, bGroup.priority, Time.frameCount);
#endif
                    bundleGroundQueue.AddBefore(fristNode, bGroup);
                    flag = true;
                    break;
                }
            }

            if (!flag)
            {
#if HUGULA_LOADER_DEBUG
                HugulaDebug.FilterLogFormat("LoadGroupAsset", "<color=#05AA01>0.0 LoadGroupAsset AddLast BundleGroundQueue(Count={0}priority={1}) frameCount{2}</color>", bGroup.Count, bGroup.priority, Time.frameCount);
#endif
                bundleGroundQueue.AddLast(bGroup);
            }

            LoadingQueue();
        }
Beispiel #6
0
        /// <summary>
        /// for lua加载ab资源
        /// </summary>
        /// <param name="reqs"></param>
        static public void LoadLuaTable(LuaTable reqs, System.Action <bool> groupCompleteFn, System.Action <LoadingEventArg> groupProgressFn, int priority = 0)
        {
            var groupQueue = BundleGroundQueue.Get();

            groupQueue.priority   = priority;
            groupQueue.onComplete = groupCompleteFn;
            groupQueue.onProgress = groupProgressFn;

            //
            foreach (var req in reqs)
            {
                groupQueue.Enqueue((CRequest)req.value);
            }

            LoadGroupAsset(groupQueue);
        }
Beispiel #7
0
 public static void Release(BundleGroundQueue toRelease)
 {
     objectPool.Release(toRelease);
 }
Beispiel #8
0
 private static void m_ActionOnRelease(BundleGroundQueue re)
 {
     re.onComplete = null;
     re.onProgress = null;
 }
Beispiel #9
0
 private static void m_ActionOnRelease(BundleGroundQueue re)
 {
     re.Reset();
 }