1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using UnityEngine.Events;
- using UnityEngine.UI;
- public class WarningUI : BaseUI
- {
- public delegate void OnYesClick();
- public delegate void OnNoClick();
- private Button yesButton;
- private Button noButton;
- private Text label;
- private OnYesClick nowClick;
- private OnNoClick NoClick;
- protected override void OnShow(WarningUI.OnYesClick onYesClick, object param)
- {
- base.OnShow(onYesClick, param);
- nowClick = onYesClick;
- label.text = param.ToString();
- }
- protected override void OnShow(OnYesClick onYesClick, OnNoClick onNoClick, object param)
- {
- base.OnShow(onYesClick, onNoClick, param);
- nowClick = onYesClick;
- NoClick = onNoClick;
- label.text = param.ToString();
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- protected override void OnAwake()
- {
- base.OnAwake();
- }
- protected override void OnInit()
- {
- base.OnInit();
- base.CacheTransform.SetAsLastSibling();
- this.yesButton = base.transform.Find("Content/Yes").GetComponent<Button>();
- this.noButton = base.transform.Find("Content/No").GetComponent<Button>();
- this.label = base.transform.Find("Content/Label").GetComponent<Text>();
- this.yesButton.onClick.AddListener(new UnityAction(this.OnClickYes));
- this.noButton.onClick.AddListener(new UnityAction(this.OnClickNo));
- }
- private void OnClickYes()
- {
- if (nowClick != null)
- {
- nowClick();
- }
- Hide();
- }
- private void OnClickNo()
- {
- if (NoClick != null)
- {
- NoClick();
- }
- Hide();
- }
- }
|