diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmInitGame.cs b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmInitGame.cs index 763eb76..1843276 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmInitGame.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmInitGame.cs @@ -4,6 +4,7 @@ using UnityEngine; using UniFramework.Pooling; using UniFramework.Window; using UniFramework.Machine; +using UniFramework.Module; using YooAsset; internal class FsmInitGame : IStateNode @@ -16,7 +17,19 @@ internal class FsmInitGame : IStateNode } void IStateNode.OnEnter() { - var handle = YooAssets.LoadAssetSync("UICanvas"); + UniModule.StartCoroutine(Prepare()); + } + void IStateNode.OnUpdate() + { + } + void IStateNode.OnExit() + { + } + + private IEnumerator Prepare() + { + var handle = YooAssets.LoadAssetAsync("UICanvas"); + yield return handle; var canvas = handle.InstantiateSync(); var desktop = canvas.transform.Find("Desktop").gameObject; GameObject.DontDestroyOnLoad(canvas); @@ -29,10 +42,4 @@ internal class FsmInitGame : IStateNode _machine.ChangeState(); } - void IStateNode.OnUpdate() - { - } - void IStateNode.OnExit() - { - } } \ No newline at end of file