52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace Game
|
|
{
|
|
[UITypeAttribute(UIType.LoadingGameSceneUI)]
|
|
public class LoadingGameSceneUI : UIBase
|
|
{
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
EventManager.Instance.Subscribe(LoadingGameSceneFinishEventArgs.EventId, LoadingGameSceneFinishEvent);
|
|
}
|
|
|
|
private void LoadingGameSceneFinishEvent(object sender, GameEventArgs e)
|
|
{
|
|
if (e is LoadingGameSceneFinishEventArgs args && args.IsFinish)
|
|
{
|
|
_task.TrySetResult();
|
|
}
|
|
}
|
|
|
|
public override void Open()
|
|
{
|
|
base.Open();
|
|
UniTask.Create(WaitLoadingFinish);
|
|
Debug.Log("hhhhhhh");
|
|
}
|
|
|
|
private UniTaskCompletionSource _task;
|
|
|
|
private async UniTask WaitLoadingFinish()
|
|
{
|
|
Debug.Log("开始循环等待");
|
|
while (true)
|
|
{
|
|
if (_task.Task.Status == UniTaskStatus.Succeeded)
|
|
{
|
|
break;
|
|
}
|
|
|
|
Debug.Log("循环等待");
|
|
|
|
await UniTask.Yield();
|
|
}
|
|
|
|
Debug.Log("循环等待完成");
|
|
}
|
|
}
|
|
} |