70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
public class AlertManager : UnitySingleton<AlertManager>
|
|
{
|
|
private GameObject prefab;
|
|
private UIAlert alert;
|
|
|
|
|
|
private void Create()
|
|
{
|
|
if (alert == null)
|
|
{
|
|
if (prefab == null)
|
|
{
|
|
prefab = Resources.Load("Prefabs/Popup/UIAlert", typeof(GameObject)) as GameObject;
|
|
}
|
|
GameObject go = UnityEngine.Object.Instantiate(prefab);
|
|
alert = go.GetComponent<UIAlert>();
|
|
}
|
|
//var canvas = FindAnyObjectByType<Canvas_Label>();
|
|
//alert.transform.SetParent(canvas.Canvas.rootCanvas.transform, false);
|
|
}
|
|
|
|
//public async UniTask ShowAlert(string title, string message, string okButtonTitle = "OK")
|
|
//{
|
|
// Create();
|
|
|
|
// bool isClosed = false;
|
|
|
|
// alert.Init(title: title, message: message, okButtonText: okButtonTitle, showCancelButton: false);
|
|
// alert.OnOk.AddListener(() =>
|
|
// {
|
|
// isClosed = true;
|
|
// });
|
|
// alert.Open();
|
|
// await UniTask.WaitUntil(() => isClosed == true);
|
|
//}
|
|
|
|
//public async UniTask<bool> ShowConfirm(string title, string message, string okButtonTitle = "OK", string cancelButtonTitle = "CANCEL")
|
|
//{
|
|
// Create();
|
|
|
|
// bool isClosed = false;
|
|
// bool result = false;
|
|
|
|
// alert.Init(title, message, okButtonTitle, cancelButtonTitle, true);
|
|
|
|
// alert.OnOk.AddListener(() =>
|
|
// {
|
|
// result = true;
|
|
// isClosed = true;
|
|
// });
|
|
|
|
// alert.OnCancel.AddListener(() =>
|
|
// {
|
|
// result = false;
|
|
// isClosed = true;
|
|
// });
|
|
|
|
// alert.Open();
|
|
|
|
|
|
// await UniTask.WaitUntil(() => isClosed == true);
|
|
|
|
// return result;
|
|
//}
|
|
|
|
}
|