Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public static void Release(AssetBundleLoadAssetOperationFull toRelease)
 {
     webOperationPool.Release(toRelease);
 }
Exemplo n.º 4
0
 private static void m_ActionOnRelease(AssetBundleLoadAssetOperationFull op)
 {
     op.Reset();
 }
Exemplo n.º 5
0
 private static void m_ActionOnGet(AssetBundleLoadAssetOperationFull op)
 {
     op.pool = true;
 }
Exemplo n.º 6
0
        /// <summary>
        /// load assetbundle
        /// </summary>
        /// <param name="req"></param>
        static protected void LoadAssetBundle(CRequest req)
        {
#if UNITY_EDITOR
            if (ManifestManager.SimulateAssetBundleInEditor)
            {
                //load asset
                ResourcesLoadOperation operation1;
                var tp1 = req.assetType;

                if (req.assetOperation != null)
                {
                    operation1 = req.assetOperation;
                }
                else if (CacheManager.Typeof_ABScene.Equals(tp1))
                {
                    operation1 = new AssetBundleLoadLevelSimulationOperation();
                    operation1.SetRequest(req);
                }
                else
                {
                    operation1 = new AssetBundleLoadAssetOperationSimulation();
                    operation1.SetRequest(req);
                }

                bool isLoading1 = false;

                if (operation1 is AssetBundleLoadAssetOperation)
                {
                    isLoading1 = AddAssetBundleLoadAssetOperationToCallBackList((AssetBundleLoadAssetOperation)operation1);
                }

                if (!isLoading1)
                {
                    inProgressOperations.Add(operation1);
                    loadingTasks.Add(req);
                }
                return;
            }
#endif
            //remove delay unload assetbundle
            ABDelayUnloadManager.CheckRemove(req.keyHashCode);

            //check load asset from cache
            if (LoadAssetFromCache(req))
            {
                DispatchReqAssetOperation(req, false);
                return;
            }

            totalCount++;//count ++
#if HUGULA_PROFILER_DEBUG
            Profiler.BeginSample(string.Format("LoadAssetBundle ({0},{1},{2}) LoadDependencies and LoadAssetBundleInternal", req.assetName, req.key, req.isShared));
#endif
            AssetBundleDownloadOperation abDownloadOperation = null;

            if (downloadingBundles.TryGetValue(req.key, out abDownloadOperation)) //check is loading
            {
            }
            else if (CheckAssetBundleCanLoad(req)) //need load
            {
                //load dependencies and refrenece count
                if (ManifestManager.fileManifest != null)
                {
                    req.dependencies = LoadDependencies(req); //load dependencies assetbundle
                }
                //load assetbundle
                abDownloadOperation = LoadAssetBundleInternal(req);
            }
#if HUGULA_PROFILER_DEBUG
            Profiler.EndSample();
#endif

#if HUGULA_PROFILER_DEBUG
            Profiler.BeginSample(string.Format("LoadAssetBundle  ({0},{1},{2}) to inProgressOperations", req.assetName, req.key, req.isShared));
#endif
            //load asset
            ResourcesLoadOperation operation;
            var tp = req.assetType;

            if (req.assetOperation != null)
            {
                operation = req.assetOperation;
            }
            else if (CacheManager.Typeof_ABScene.Equals(tp))
            {
                operation = new AssetBundleLoadLevelOperation();
                operation.SetRequest(req);
            }
            else
            {
                operation = AssetBundleLoadAssetOperationFull.Get();
                operation.SetRequest(req);
            }

            bool isLoading = false;
            //the same asset be one Operation
            if (operation is AssetBundleLoadAssetOperation)
            {
                isLoading = AddAssetBundleLoadAssetOperationToCallBackList((AssetBundleLoadAssetOperation)operation);
            }

            if (!isLoading)
            {
                if (abDownloadOperation != null)
                {
                    abDownloadOperation.AddNext(operation);//wait for assetbunle complete
                }
                else
                {
                    inProgressOperations.Add(operation);// the assetbundle is done
                }
                loadingTasks.Add(req);
            }
#if HUGULA_PROFILER_DEBUG
            Profiler.EndSample();
#endif
#if HUGULA_LOADER_DEBUG
            HugulaDebug.FilterLogFormat(req.key, "<color=#15A0A1>2.0 LoadAssetBundle Asset 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
        }