105 lines
2.1 KiB
C#
105 lines
2.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Cysharp.Threading.Tasks;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.UIElements;
|
|
using Button = UnityEngine.UI.Button;
|
|
using Image = UnityEngine.UI.Image;
|
|
using Toggle = UnityEngine.UI.Toggle;
|
|
using ScrollView = PhxhSDK.PhxhScrollView;
|
|
using Framework;
|
|
|
|
public class UI_ConfirmController : UIWindow
|
|
{
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
public Button Button_Close;
|
|
public Button Button_Cancel;
|
|
public Button Button_Confirm;
|
|
public TMP_Text Text_Content;
|
|
public Image Image_TopBlackBar;
|
|
public Image Image_BottomBlackBar;
|
|
|
|
///Auto Gen End///
|
|
|
|
private struct OpenData
|
|
{
|
|
public string title;
|
|
public string content;
|
|
public Action okFunc;
|
|
public Action cancelFunc;
|
|
}
|
|
|
|
private OpenData _openData;
|
|
|
|
public static async UniTask<UIWindow> Open(string content, Action okFunc, Action cancelFunc, string okText, string cancelText)
|
|
{
|
|
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_Confirm, new OpenData()
|
|
{
|
|
//title = title,
|
|
content = content,
|
|
okFunc = okFunc,
|
|
cancelFunc = cancelFunc
|
|
});
|
|
}
|
|
// deal with input data
|
|
public override void PreLoad(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
// Use this for initialization
|
|
public override void OnInit()
|
|
{
|
|
//bind UI GameObj
|
|
UI_ConfirmBinder.GetComponents(this);
|
|
|
|
BindButton(Button_Confirm, _OnClickConfirm);
|
|
BindButton(Button_Cancel, _OnClickCancel);
|
|
BindButton(Button_Close, _OnClickClose);
|
|
}
|
|
|
|
//invoke when open window
|
|
protected override void OnShowWindow(object data = null)
|
|
{
|
|
Text_Content.text = _openData.content;
|
|
}
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when close window
|
|
protected override void OnHideWindow()
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when destroy
|
|
public override void OnRelease()
|
|
{
|
|
base.OnRelease();
|
|
}
|
|
|
|
private void _OnClickClose()
|
|
{
|
|
CloseWindow();
|
|
}
|
|
|
|
private void _OnClickConfirm()
|
|
{
|
|
_openData.okFunc?.Invoke();
|
|
CloseWindow();
|
|
}
|
|
|
|
private void _OnClickCancel()
|
|
{
|
|
_openData.cancelFunc?.Invoke();
|
|
CloseWindow();
|
|
}
|
|
} |