少年修仙传客户端代码仓库
client_Wu Xijin
2018-10-26 86b0e47ed7ac943c549a150dd88a31647eb60675
4334 【前端】随包资源支持热更 当下载到随包资源时,重新加载assetbundle信息
2个文件已修改
63 ■■■■■ 已修改文件
Core/ResModule/AssetBundle/AssetBundleUtility.cs 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/DownLoadAndDiscompressTask.cs 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/ResModule/AssetBundle/AssetBundleUtility.cs
@@ -42,6 +42,51 @@
        assetBundle = null;
    }
    public void ReInitBuiltInAsset()
    {
        var path = AssetVersionUtility.GetBuiltInAssetFilePath("builtin_assetbundle");
        var assetBundle = AssetBundle.LoadFromFile(path);
        if (assetBundle == null)
        {
            DebugEx.LogError("AssetBundleManifest的包文件为空或者加载出错.");
        }
        var manifest = assetBundle.LoadAsset<AssetBundleManifest>(ResourcesPath.AssetDependentFileAssetName);
        if (manifest == null)
        {
            DebugEx.LogError("AssetBundleManifest文件为空或者加载出错.");
        }
        for (int i = m_AssetBundleInfoList.Count - 1; i >= 0; i--)
        {
            var item = m_AssetBundleInfoList[i];
            if (item.name.Contains("builtin"))
            {
                m_AssetBundleInfoList.Remove(item);
            }
        }
        foreach (var item in m_AssetBundleDict.Keys)
        {
            if (item.Contains("builtin"))
            {
                m_AssetBundleDict.Remove(item);
            }
        }
        var bundles = manifest.GetAllAssetBundles();
        foreach (var bundle in bundles)
        {
            var dependenices = manifest.GetAllDependencies(bundle);
            var hash = manifest.GetAssetBundleHash(bundle);
            var assetBundleInfo = new AssetBundleInfo(bundle, hash, dependenices);
            m_AssetBundleInfoList.Add(assetBundleInfo);
        }
        assetBundle.Unload(true);
        assetBundle = null;
    }
    public IEnumerator Initialize()
    {
        yield return StartCoroutine(Co_LoadMainfestFile("audio"));
System/AssetVersion/DownLoadAndDiscompressTask.cs
@@ -18,17 +18,16 @@
    public int totalCount { get; private set; }
    public int okCount { get; private set; }
    public bool restartApp { get; private set; }
    public bool reinitedBuiltInAsset { get; private set; }
    public event Action<Step> downLoadStepChangeEvent;
    Action downLoadOkCallBack;
    Step m_Step = Step.None;
    public Step step
    {
    public Step step {
        get { return m_Step; }
        set
        {
        set {
            if (m_Step != value)
            {
                m_Step = value;
@@ -50,6 +49,7 @@
        okCount = 0;
        step = Step.DownLoadPrepared;
        restartApp = false;
        reinitedBuiltInAsset = false;
        totalSize = 0;
        for (int i = 0; i < tasks.Count; i++)
@@ -62,6 +62,11 @@
                restartApp = true;
            }
#endif
            if (!reinitedBuiltInAsset && task.relativePath.Contains("builtin"))
            {
                reinitedBuiltInAsset = true;
            }
        }
        if (totalSize > BYTE_PER_MILLIONBYTE)
@@ -121,6 +126,11 @@
        {
            SDKUtility.Instance.RestartApp();
        }
        if (reinitedBuiltInAsset)
        {
            AssetBundleUtility.Instance.ReInitBuiltInAsset();
        }
    }
    private void OnFileDownLoadCompleted(bool _ok, AssetVersion _assetVersion)