Ejemplo n.º 1
0
        /** 计算新的更新包的资源大小 */
        public static void countNewVersionSize(VersionSaveData data, VersionReData re)
        {
            re.size         = 0;
            re.isOnlyConfig = true;

            data.resourceDic.forEachValue(v =>
            {
                ResourceSaveData oldData = _versionData.resourceDic.get(v.name);

                if (oldData != null)
                {
                    //需要下载的部分
                    if (oldData.version < v.version ||
                        (v.state == ResourceSaveStateType.None && ResourceSaveType.needFirst(v.saveType) && oldData.state == ResourceSaveStateType.None))
                    {
                        re.size += v.size;

                        if (re.isOnlyConfig && !v.name.StartsWith(ShineGlobal.configDirPath))
                        {
                            re.isOnlyConfig = false;
                        }
                    }
                }
            });

            if (re.size == 0)
            {
                re.isOnlyConfig = false;
            }
        }
Ejemplo n.º 2
0
        /** 与旧版本资源合并(并且删除旧资源) */
        public static void mergeVersion(VersionSaveData data)
        {
            data.resourceDic.forEachValue(v =>
            {
                ResourceSaveData oldData = _versionData.resourceDic.get(v.name);

                if (oldData != null)
                {
                    oldData.dided = true;
                    //版本不足(或调试版)
                    if (oldData.version < v.version || !data.isRelease)
                    {
                        //删除
                        deleteCacheResoruce(oldData.name);
                    }
                    //相同版本
                    else
                    {
                        //且已下载好的
                        if (oldData.state == ResourceSaveStateType.Downloaded)
                        {
                            v.state = ResourceSaveStateType.Downloaded;
                        }
                    }

                    //需要进包的部分
                    if (v.saveType == ResourceSaveType.InStreamingAsset)
                    {
                        ResourceSaveData pData = _packVersionData.resourceDic.get(v.name);

                        //包内资源相同
                        if (pData != null && pData.version == v.version)
                        {
                            v.state = ResourceSaveStateType.StreamingAssetsReady;
                        }
                    }
                }
            });

            _versionData.resourceDic.forEachValue(v =>
            {
                if (!v.dided)
                {
                    //删除
                    deleteCacheResoruce(v.name);
                }

                v.dided = false;
            });

            _versionData     = data;
            _versionModified = true;
        }
Ejemplo n.º 3
0
        /** 获取资源当前保存路径 */
        public static string getResourceSavePath(string url)
        {
            ResourceSaveData data = getResourceSaveData(url);

            if (data == null)
            {
                Ctrl.throwError("不该找不到资源数据", url);
                return("");
            }

            if (data.state == ResourceSaveStateType.StreamingAssetsReady)
            {
                return(getStreamingAssetsPath(url, false));
            }
            else if (data.state == ResourceSaveStateType.Downloaded)
            {
                return(getPersistentPath(url, false));
            }
            else
            {
                Ctrl.throwError("资源数据保存类型不对", url);
                return("");
            }
        }
Ejemplo n.º 4
0
        /** 执行加载 */
        private void toLoad()
        {
            _needSize = 0;

            switch (_loadMethod)
            {
            case LoadMethodType.Resource:
            {
                if (ShineSetting.debugJumpResourceVersion || ShineSetting.localLoadWithOutBundle)
                {
                    _needSize     = 0;
                    _useURL       = ResourceInfoControl.getStreamingAssetsPath(_url, true);
                    _resourceType = ResourceType.Unknown;
                }
                else
                {
                    if ((_currentSaveData = ResourceInfoControl.getResourceSaveData(_url)) == null)
                    {
                        Ctrl.throwError("不该找不到资源数据", _url);
                        return;
                    }

                    _resourceType = _currentSaveData.getType();
                    bool isBundle = _resourceType == ResourceType.Bundle;

                    _needSize = _currentSaveData.size;

                    //从steamingAsset中加载
                    if (_currentSaveData.state == ResourceSaveStateType.StreamingAssetsReady)
                    {
                        _useURL = ResourceInfoControl.getStreamingAssetsPath(_url, !isBundle);
                    }
                    //从持久化中加载
                    else if (_currentSaveData.state == ResourceSaveStateType.Downloaded)
                    {
                        _useURL = ResourceInfoControl.getPersistentPath(_url, !isBundle);
                    }
                    //需要加载
                    else
                    {
                        _useURL    = ResourceInfoControl.getCDNResourcePath(_url, _currentSaveData.version);
                        _needCache = true;
                    }
                }
            }
            break;

            case LoadMethodType.StreamingAssets:
            {
                _useURL       = ResourceInfoControl.getStreamingAssetsPath(_url, true);
                _resourceType = ResourceType.Unknown;
            }
            break;

            default:
            {
                _useURL       = _url;
                _resourceType = ResourceType.Unknown;
            }
            break;
            }

            _reloadTimes = 0;
            //标记开始加载
            _loadState = LoadState_Loading;

            resetTimeOut();
            toDoLoad();
        }
Ejemplo n.º 5
0
 /** 清除部分数据 */
 private void clear()
 {
     _needSize        = 0;
     _currentSaveData = null;
     _needCache       = false;
 }