YooAsset/Assets/Samples~/BasicSample/Script/Runtime/PatchUpdater/FsmNode/FsmDownloadWebFiles.cs

36 lines
889 B
C#
Raw Normal View History

2022-07-18 14:56:12 +08:00
using System.Collections;
using YooAsset;
public class FsmDownloadWebFiles : IFsmNode
{
public string Name { private set; get; } = nameof(FsmDownloadWebFiles);
void IFsmNode.OnEnter()
{
PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.DownloadWebFiles);
BootScene.Instance.StartCoroutine(BeginDownload());
}
void IFsmNode.OnUpdate()
{
}
void IFsmNode.OnExit()
{
}
private IEnumerator BeginDownload()
{
var downloader = PatchUpdater.Downloader;
// 注册下载回调
downloader.OnDownloadErrorCallback = PatchEventDispatcher.SendWebFileDownloadFailedMsg;
downloader.OnDownloadProgressCallback = PatchEventDispatcher.SendDownloadProgressUpdateMsg;
downloader.BeginDownload();
yield return downloader;
// 检测下载结果
if (downloader.Status != EOperationStatus.Succeed)
yield break;
FsmManager.Transition(nameof(FsmPatchDone));
}
}