LaboratoryProtection/Assets/PMaker/Scripts/Await/UI/UIDefaultAll.cs

21 lines
600 B
C#
Raw Permalink Normal View History

2023-09-12 15:55:51 +08:00
using Cysharp.Threading.Tasks;
using System.Threading;
using UnityEngine.UI;
namespace PMaker.Await.UI
{
public class UIDefaultAll : AwaitBehaviour
{
public override async UniTask WaitAsync(CancellationToken cancellationToken = default)
{
this.SetFalse();
var btns = this.transform.GetComponentsInChildren<Button>(true).Select(_ => _.OnClickAsync(cancellationToken));
this.gameObject.SetActive(true);
await UniTask.WhenAll(btns).SuppressCancellationThrow();
this.gameObject.SetActive(false);
}
}
}