96 lines
2.7 KiB
C#
96 lines
2.7 KiB
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using Studio.Core;
|
|
using XRLib;
|
|
|
|
namespace Studio.UI.Popup
|
|
{
|
|
public class UIAlertManager : UnitySingleton<UIAlertManager>
|
|
{
|
|
private GameObject prefab;
|
|
private UIAlert alert;
|
|
|
|
//public override void AfterAwake()
|
|
//{
|
|
// base.AfterAwake();
|
|
// SceneManager.sceneUnloaded += OnSceneUnloaded;
|
|
//}
|
|
|
|
//private void OnSceneUnloaded(Scene arg0)
|
|
//{
|
|
// if (alert != null) alert.transform.SetParent(null, false);
|
|
//}
|
|
|
|
//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;
|
|
//}
|
|
|
|
//public void ShowWinAlert(string title, string message)
|
|
//{
|
|
// WindowTools.Alert(title, message);
|
|
//}
|
|
|
|
//public bool ShowWinConfirm(string title, string message)
|
|
//{
|
|
// // bool result = WindowTools.Confirm(title, message);
|
|
// return false;
|
|
//}
|
|
|
|
}
|
|
}
|