TheInitialProject/Assets/Scripts/UI/Tips/TipChoiceUnit.cs
2024-10-23 16:59:02 +08:00

73 lines
1.4 KiB
C#

// Author: whc
// Desc:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TipChoiceUnit : TipDialogUnit
{
public Button m_BtnClose;
public new ChoiceData m_Data;
public override void Awake()
{
base.Awake();
m_BtnClose = transform.Find("btnClose").GetComponent<Button>();
}
public override void OnEnable()
{
base.OnEnable();
m_BtnClose.onClick.AddListener(OnBtnCloseClick);
}
public override void OnDisable()
{
base.OnDisable();
m_BtnClose.onClick.RemoveAllListeners();
}
public override void Refresh(TipData _Data)
{
base.Refresh(_Data);
m_Data = (_Data as ChoiceData);
}
public override void OnBtnYesClick()
{
base.OnBtnYesClick();
if (m_Data == null)
{
Debug.LogError("OnBtnYesClick Error, m_Data == null");
return;
}
if (m_Data.m_YesCall == null)
{
Debug.LogWarning("OnBtnYesClick Warn, m_Data.m_Call == null");
return;
}
//Debug.Log("OnBtnYesClick. xxxxx. m_Data.m_YesCall");
m_Data.m_YesCall();
}
public override void OnBtnCloseClick()
{
base.OnBtnCloseClick();
if (m_Data.m_NoCall != null)
m_Data.m_NoCall();
}
}