目录
正文
前文介绍过,下载的所有AB包文件都在临时文件夹里,到了这一步,证明包全部下载完成,可以放心的移动到Unity的沙盒目录下了。persistentDataPath是有读写权限的。
IEnumerator DeployDownloadFiles()
{
var downloadDir = AssetPathHelper.MakeDownloadTempPath("");
var deployDir = AssetPathHelper.MakePersistentLoadPath("");
// PatchEventDispatcher.SendDeployPatchProgressMsg(totalDownloadCount, 0);
//merge main pack
var patchMainPack = FileSystemManagerBase.Instance.GetSandboxFileSystem(PatchDefine.MainPackKey);
if (patchMainPack != null)
{
var dataPath = $"{downloadDir}/{patchMainPack.Name}.pak";
if (File.Exists(dataPath)) File.Delete(dataPath);
var start = Time.realtimeSinceStartup;
yield return patchMainPack.MergeAsync(downloadDir, OnDeployProgress);
MotionLog.Log(ELogLevel.Log, $"<color=#ffdd00>Deploy downloads cost {Time.realtimeSinceStartup - start} seconds.</color>");
//delete old pak file
patchMainPack.DeletePersistantFile();
File.Move(Path.Combine(downloadDir, PatchDefine.MainPakFileName), Path.Combine(deployDir, PatchDefine.MainPakFileName));
FileUtils.DeleteDir(downloadDir);
}
else
{
var op = FileUtils.CopyFilesAsync(downloadDir, deployDir);
while (op.keepWaiting)
{
// OnDeployProgress(totalDownloadCount, op.finishedCount);
yield return _generalInterval;
}
FileUtils.DeleteDir(downloadDir);
}
PatchEventDispatcher.SendPatchStatesChangeMsg(EPatchStates.DownloadOver);
}
完成这一步后,启动热更新的内容就全部结束啦,但是!!游戏内热更新还没有讲,下一篇就开始游戏内热更新。