mirror of https://github.com/tuyoogame/YooAsset
50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UniFramework.Machine;
|
|
using UniFramework.Module;
|
|
using YooAsset;
|
|
|
|
/// <summary>
|
|
/// 更新资源版本号
|
|
/// </summary>
|
|
internal class FsmUpdateVersion : IStateNode
|
|
{
|
|
private StateMachine _machine;
|
|
|
|
void IStateNode.OnCreate(StateMachine machine)
|
|
{
|
|
_machine = machine;
|
|
}
|
|
void IStateNode.OnEnter()
|
|
{
|
|
PatchEventDefine.PatchStatesChange.SendEventMessage("获取最新的资源版本 !");
|
|
UniModule.StartCoroutine(GetStaticVersion());
|
|
}
|
|
void IStateNode.OnUpdate()
|
|
{
|
|
}
|
|
void IStateNode.OnExit()
|
|
{
|
|
}
|
|
|
|
private IEnumerator GetStaticVersion()
|
|
{
|
|
yield return new WaitForSecondsRealtime(0.5f);
|
|
|
|
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
|
var operation = package.UpdatePackageVersionAsync(30);
|
|
yield return operation;
|
|
|
|
if (operation.Status == EOperationStatus.Succeed)
|
|
{
|
|
PatchManager.Instance.PackageVersion = operation.PackageVersion;
|
|
_machine.ChangeState<FsmUpdateManifest>();
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning(operation.Error);
|
|
PatchEventDefine.PackageVersionUpdateFailed.SendEventMessage();
|
|
}
|
|
}
|
|
} |