Пример #1
0
        public void ReduceRef(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                LogModule.ErrorLog("BaseResCached.ReduceRef called but url is IsNullOrEmpty!");
                return;
            }
            if (!_cachedBundleDic.ContainsKey(url))
            {
                LogModule.ErrorLog("BaseResCached.ReduceRef called but url {0} is not in cached!!", url);
                return;
            }
            SCachedBundleData data = _cachedBundleDic[url];

            data.RefCount--;
            _cachedBundleDic[url] = data;
        }
Пример #2
0
        /// <summary>
        /// 增加引用
        /// </summary>
        /// <param name="url"></param>
        public void AddRef(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                LogModule.ErrorLog("BaseResCached.AddRef called but url is IsNullOrEmpty!");
                return;
            }
            if (!_cachedBundleDic.ContainsKey(url))
            {
                LogModule.ErrorLog("BaseResCached.AddRef called but url {0} is not in cached!!", url);
                return;
            }
            SCachedBundleData data = _cachedBundleDic[url];

            data.RefCount++;
            data.LastAccessTime   = Time.realtimeSinceStartup;
            _cachedBundleDic[url] = data;
        }
Пример #3
0
        public bool Update()
        {
            float curTime    = Time.realtimeSinceStartup;
            var   enumerator = _cachedBundleDic.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (_curIndex >= MaxClearCountPreFrame)
                {
                    break;
                }
                SCachedBundleData data = enumerator.Current.Value;
                if (data.RefCount <= 0 && curTime - data.LastAccessTime > MaxClearTime)
                {
                    _needToRemoveArray[_curIndex] = enumerator.Current.Key;
                    _curIndex++;
                }
            }
            bool res = _needToUnloadUnusedAssetNextFrame;

            _needToUnloadUnusedAssetNextFrame = ClearCurFrameCache();
            _lastTickTime = Time.realtimeSinceStartup;
            return(res);
        }