/// <summary> /// append request to assetCallBackList /// </summary> /// <param name="AssetBundleLoadAssetOperation">operation.</param> static protected bool AddAssetBundleLoadAssetOperationToCallBackList(AssetBundleLoadAssetOperation operation) { bool isLoading = false; var req = operation.cRequest; string key = req.udAssetKey; List <CRequest> list = null; if (assetCallBackList.TryGetValue(key, out list)) //回调列表 { list.Add(req); isLoading = true; operation.ReleaseToPool(); } else { list = ListPool <CRequest> .Get(); assetCallBackList.Add(key, list); list.Add(req); } #if HUGULA_LOADER_DEBUG HugulaDebug.FilterLogFormat(req.key, "<color=#ffff00>2.0.0 AddAssetBundleLoadAssetOperationToCallBackList Request(url={0},assetname={1},keyHashCode{2},asyn={4}) list.count={3}, frameCount{5}</color>", req.url, req.assetName, req.keyHashCode, list.Count, req.async, Time.frameCount); #endif return(isLoading); }
/// <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); }
/// <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); }
/// <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(); } } }
/// <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(); } }
/// <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(); } }