Skip to content

Commit

Permalink
[修复]1. 修复Offline 模式的时候启动异常
Browse files Browse the repository at this point in the history
  • Loading branch information
AlianBlank committed Aug 19, 2024
1 parent 18edf68 commit 73d3c4e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ protected override async void OnEnter(IFsm<IProcedureManager> procedureOwner)

if (GameApp.Asset.GamePlayMode == EPlayMode.OfflinePlayMode)
{
Log.Info("当前为离线模式,直接启动 ProcedureGameLauncherState");
Log.Info("当前为离线模式,直接启动 ProcedureUpdateStaticVersion");
await GameApp.Asset.InitPackageAsync(AssetComponent.BuildInPackageName, string.Empty, string.Empty, true);
ChangeState<ProcedureGameLauncherState>(procedureOwner);
ChangeState<ProcedureUpdateStaticVersion>(procedureOwner);
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using GameFrameX.Asset.Runtime;
using GameFrameX.Fsm.Runtime;
Expand All @@ -11,10 +12,20 @@ namespace GameFrameX.Procedure
{
internal sealed class ProcedureUpdateManifest : ProcedureBase
{
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
protected override async void OnEnter(IFsm<IProcedureManager> procedureOwner)
{
base.OnEnter(procedureOwner);

if (GameApp.Asset.GamePlayMode == EPlayMode.OfflinePlayMode)
{
var varStringVersion = procedureOwner.GetData<VarString>(AssetComponent.BuildInPackageName + "Version");
var buildInResourcePackage = GameApp.Asset.GetAssetsPackage(AssetComponent.BuildInPackageName);
var buildInOperation = buildInResourcePackage.UpdatePackageManifestAsync(varStringVersion.Value);
await buildInOperation.ToUniTask();
ChangeState<ProcedurePatchDone>(procedureOwner);
return;
}

GameApp.Event.Fire(this, AssetPatchStatesChangeEventArgs.Create(AssetComponent.BuildInPackageName, EPatchStates.UpdateManifest));
UpdateManifest(procedureOwner).ToUniTask();
}
Expand All @@ -24,7 +35,7 @@ private IEnumerator UpdateManifest(IFsm<IProcedureManager> procedureOwner)
{
yield return new WaitForSecondsRealtime(0.1f);

var buildInResourcePackage = YooAssets.GetPackage(AssetComponent.BuildInPackageName);
var buildInResourcePackage = YooAssets.GetPackage(AssetComponent.BuildInPackageName);
UpdatePackageManifestOperation buildInOperation;
if (GameApp.Asset.GamePlayMode == EPlayMode.EditorSimulateMode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using GameFrameX.Asset.Runtime;
using GameFrameX.Fsm.Runtime;
using GameFrameX.Procedure.Runtime;
using GameFrameX.Runtime;
using UnityEngine;
using YooAsset;

Expand Down Expand Up @@ -30,6 +31,13 @@ private IEnumerator GetStaticVersion(IFsm<IProcedureManager> procedureOwner)
{
//更新成功
string packageVersion = buildInOperation.PackageVersion;
if (GameApp.Asset.GamePlayMode == EPlayMode.OfflinePlayMode)
{
var varStringVersion = ReferencePool.Acquire<VarString>();
varStringVersion.SetValue(packageVersion);
procedureOwner.SetData(AssetComponent.BuildInPackageName + "Version", varStringVersion);
}

Debug.Log($"Updated package Version : {packageVersion}");
ChangeState<ProcedureUpdateManifest>(procedureOwner);
}
Expand Down

0 comments on commit 73d3c4e

Please sign in to comment.