LaboratoryProtection/Assets/UnityTest/UI/Scripts/Await/MoudleSelectSlider.cs

43 lines
1.1 KiB
C#

using Cysharp.Threading.Tasks;
using PMaker.Await;
using System;
using System.Threading;
using UnityEngine;
using UnityEngine.UI;
public class MoudleSelectSlider : AwaitBehaviour
{
[SerializeField]
private UIMultimodule _multimodule;
[SerializeField]
private Button _nextBtn;
public int Max { get => _multimodule.Max; }
public override UniTask WaitAsync(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
private void Reset()
{
_multimodule = this.GetComponentInChildren<UIMultimodule>(true);
_nextBtn = this.GetComponentInChildren<Button>(true);
}
public async UniTask WaitAsync(Func<CancellationToken, UniTask>[] logics, CancellationToken cancellationToken)
{
this.gameObject.SetActive(true);
var result = await _multimodule.WaitAsync(logics, cancellationToken).SuppressCancellationThrow();
Debug.Log(this.name + "IsCanceled: " + result);
if (result != true)
{
await _nextBtn.OnClickAsync(cancellationToken).SuppressCancellationThrow();
}
this.gameObject.SetActive(false);
}
}