Exemplo n.º 1
0
        protected virtual void DoCompleted()
        {
            isComplete = true;

            CoroutineMgr.StopCoroutine("doLoad");

            timeElapsed = Time.time - startTime;

            isCacheHit = www != null && www.size == 0 && www.assetBundle != null;
            if (isCacheHit)
            {
                Log.Debug(logTag, string.Format("Cache hit, url: {0}, version: {1}", actualUrl, version));
            }
            else
            {
                Log.Debug(logTag, string.Format(
                              "Load complete, url: {3}, version: {2}, time: {0}s, bytesLoaded: {1}, retryCount: {5}, error: {4}",
                              timeElapsed, bytesLoaded, version, url, !hasError ? "no" : error, retryCount));
            }

            if (!hasError && www != null)
            {
                _bytesLoaded = isCacheHit ? size : www.bytesDownloaded;

                if (www.assetBundle != null)
                {
                    orgAssetBundle = www.assetBundle;
                    assetBundle    = new ResourceBundle(orgAssetBundle);
                    //only retain assetBundle, to save memery
                    if (onlyRetainAssetBundle)
                    {
                        www.Dispose();
                        www = null;
                    }
                }
            }
            else
            {
                _bytesLoaded = 0;
            }

//            onComplete.InvokeAndRemove(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Use by LoaderMgr, usually user need't use it
        /// </summary>
        public virtual void DisposeImmediate()
        {
            if (www != null)
            {
                if (orgAssetBundle != null)
                {
//                    orgAssetBundle.Unload(false);
                    orgAssetBundle = null;
                    assetBundle.Dispose();
                    assetBundle = null;
                }
                www.Dispose();
                www = null;
            }
            customData = null;
            CoroutineMgr.StopCoroutine("doLoad");
            hasDisposed = true;
            GC.SuppressFinalize(this);
        }
Exemplo n.º 3
0
        protected virtual bool Retry()
        {
            CoroutineMgr.StopCoroutine("doLoad");

            if (www != null)
            {
                www.Dispose();
                www = null;
            }

            if (retryCount >= maxRetryCount)
            {
                return(false);
            }

            retryCount++;
//            Debug.LogWarningFormat("Retry load, retryCount: {0}, url: {1}", retryCount, url);
            Load(useCache, maxRetryCount - retryCount < 2);
            return(true);
        }