AddSourceCacheDataFromWWW() static private method

Adds the source cache data from WW.
static private AddSourceCacheDataFromWWW ( WWW www, CRequest req ) : bool
www UnityEngine.WWW Www.
req CRequest Req.
return bool
Exemplo n.º 1
0
        protected void AssetBundleFileLoadDone()
        {
#if HUGULA_PROFILE_DEBUG
            Profiler.BeginSample("CCar.AssetBundleFileLoadDone:" + this.req.assetName);
#endif
            isFree  = true;
            enabled = false;

            var ab = abRequest.assetBundle;
            if (ab == null)
            {
                Debug.LogWarningFormat(" ({0}) isNormal({2}) \n error:Unable to open archive file:{1}", req.assetName, req.url, req.isNormal);
                DispatchErrorEvent(req);
                abRequest = null;
            }
            else
            {
                if (OnProcess != null)
                {
                    OnProcess(this, 1);
                }
#if HUGULA_LOADER_DEBUG
                Debug.LogFormat(" 1. <color=#8cacbc> will complete : url({0}),key:({1}) assetName({2}) frame{3})</color>", req.url, req.key, req.assetName, Time.frameCount);
#endif
                CacheManager.AddSourceCacheDataFromWWW(ab, this._req);
                DispatchCompleteEvent(this._req);
                abRequest = null;
            }
#if HUGULA_PROFILE_DEBUG
            Profiler.EndSample();
#endif
        }
Exemplo n.º 2
0
        protected void LoadDone()
        {
#if HUGULA_PROFILE_DEBUG
            Profiler.BeginSample(this.req.key, this.gameObject);
#endif
            isFree  = true;
            enabled = false;
            if (www.error != null)
            {
                Debug.LogWarning(" (" + req.assetName + ")url(" + req.url + ") \n error:" + www.error);
                DispatchErrorEvent(req);
                www = null;
            }
            else
            {
                if (OnProcess != null)
                {
                    OnProcess(this, 1);
                }
                                #if HUGULA_LOADER_DEBUG
                Debug.LogFormat(" 1. <color=#8cacbc> will complete : url({0}),key:({1}) assetName({2}) txt({3}) len({4})</color>", req.url, req.key, req.assetName, www.text, www.bytes.Length);
                                #endif
                CacheManager.AddSourceCacheDataFromWWW(www, this._req);
                DispatchCompleteEvent(this._req);
            }
#if HUGULA_PROFILE_DEBUG
            Profiler.EndSample();
#endif
        }
Exemplo n.º 3
0
        /// <summary>
        /// finish assetbundle
        /// </summary>
        /// <param name="operation"></param>
        static void ProcessFinishedBundleOperation(AssetBundleDownloadOperation operation)
        {
#if HUGULA_PROFILER_DEBUG
            Profiler.BeginSample(string.Format("ResourcesLoader.ProcessFinishedBundleOperation CRequest({0},shared={1})", operation.cRequest.assetName, operation.cRequest.isShared));
#endif
            var  req     = operation.cRequest;
            bool isError = operation.assetBundle == null;
            var  ab      = operation.assetBundle;
            AssetBundleDownloadOperation download = operation;
            if (!isError)
            {
                CacheManager.AddSourceCacheDataFromWWW(ab, req);
            }
            else
            {
#if UNITY_EDITOR
                Debug.LogWarning(operation.error);
#endif
                CacheManager.AddErrorSourceCacheDataFromReq(req);
            }
#if HUGULA_LOADER_DEBUG
            HugulaDebug.FilterLogFormat(req.key, "<color=#10f010>1.9  ProcessFinishedBundleOperation AssetBundle 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

            //begin load asset
            InsertAssetBundleLoadAssetOperation(download);

            downloadingBundles.Remove(req.key);
            download.ReleaseToPool();

            if (isError)
            {
                CallOnAssetBundleErr(req);
            }
            else
            {
                CallOnAssetBundleComplete(req, ab);
            }

            if (req.isShared)
            {
                req.ReleaseToPool();
            }
#if HUGULA_PROFILER_DEBUG
            Profiler.EndSample();
#endif
        }
Exemplo n.º 4
0
        protected void WWWLoadDone()
        {
#if HUGULA_PROFILE_DEBUG
            Profiler.BeginSample("CCar.LoadDone:" + this.req.assetName);
#endif
            isFree  = true;
            enabled = false;
            if (www.error != null)
            {
                Debug.LogWarningFormat(" ({0})url({1}) isNormal({2}) \n error:{3}", req.assetName, req.url, req.isNormal, www.error);
                if (req.isShared)
                {
                    CacheManager.AddErrorSourceCacheDataFromReq(this._req);
                }
                DispatchErrorEvent(req);
                www = null;
            }
            else
            {
                if (OnProcess != null)
                {
                    OnProcess(this, 1);
                }

#if HUGULA_LOADER_DEBUG
                Debug.LogFormat(" 1.1 <color=#15C1B2> will complete : url({0}),key:({1}) assetName({2})  len({3} frame{4})</color>", req.url, req.key, req.assetName, www.bytes.Length, Time.frameCount);
#endif
                if (req.isLoadFromCacheOrDownload) //load from cache no www.bytes
                {
                    CacheManager.AddSourceCacheDataFromWWW(www.assetBundle, this._req);
                }
                else
                {
                    CacheManager.AddSourceCacheDataFromWWW(www, this._req);
                }
                DispatchCompleteEvent(this._req);
                www = null;
            }
#if HUGULA_PROFILE_DEBUG
            Profiler.EndSample();
#endif
        }
Exemplo n.º 5
0
        void m_Done()
        {
            if (m_abRequest == null && m_UnityWebRequest == null)
            {
                cRequest.error = string.Format("the asset bundle({0}) is wrong .    CRequest({1})", cRequest.key, cRequest.assetName);
                CacheManager.AddErrorSourceCacheDataFromReq(cRequest);
                Debug.LogError(cRequest.error);
            }

            // AssetBundle assetBundle = null;

            if (m_UnityWebRequest != null)
            {
                assetBundle = DownloadHandlerAssetBundle.GetContent(m_UnityWebRequest);
            }
            else if (m_abRequest is AssetBundleCreateRequest)
            {
                assetBundle = ((AssetBundleCreateRequest)m_abRequest).assetBundle;
            }

            if (assetBundle == null)
            {
                cRequest.error = string.Format("the asset bundle({0}) is not exist. CRequest({1})", cRequest.key, cRequest.assetName);
                CacheManager.AddErrorSourceCacheDataFromReq(cRequest);
                Debug.LogError(cRequest.error);
            }
            else
            {
                CacheManager.AddSourceCacheDataFromWWW(assetBundle, cRequest);
            }

#if HUGULA_LOADER_DEBUG
            HugulaDebug.FilterLogFormat(cRequest.key, " <color=#15A0A1> 1 AssetBundle is done Request(assetName={0}) key={1},frame={2} </color>", cRequest.assetName, cRequest.key, Time.frameCount);
#endif

            m_abRequest       = null;
            m_UnityWebRequest = null;
        }