mirror of
https://github.com/tym1116/BH3.git
synced 2025-12-16 16:34:41 +01:00
60 lines
1.3 KiB
C#
60 lines
1.3 KiB
C#
using MoleMole.Config;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace MoleMole
|
|
{
|
|
public class GeneralHintDialogContext : BaseDialogContext
|
|
{
|
|
private const float TIMER_SPAN = 2f;
|
|
|
|
public string desc;
|
|
|
|
private CanvasTimer _timer;
|
|
|
|
public GeneralHintDialogContext(string desc, float timerSpan = 2f)
|
|
{
|
|
config = new ContextPattern
|
|
{
|
|
contextName = "GeneralHintDialogContext",
|
|
viewPrefabPath = "UI/Menus/Dialog/GeneralHintDialog"
|
|
};
|
|
this.desc = desc;
|
|
if (_timer != null)
|
|
{
|
|
_timer.Destroy();
|
|
}
|
|
_timer = Singleton<MainUIManager>.Instance.SceneCanvas.CreateTimer(timerSpan, 0f);
|
|
_timer.timeUpCallback = OnTimerUp;
|
|
}
|
|
|
|
protected override void BindViewCallbacks()
|
|
{
|
|
BindViewCallback(base.view.transform.Find("BG"), EventTriggerType.PointerClick, OnBGClick);
|
|
BindViewCallback(base.view.transform.Find("Dialog/Content/Btn").GetComponent<Button>(), Destroy);
|
|
}
|
|
|
|
protected override bool SetupView()
|
|
{
|
|
base.view.transform.Find("Dialog/Content/DescText").GetComponent<Text>().text = desc;
|
|
return false;
|
|
}
|
|
|
|
public void OnBGClick(BaseEventData evtData = null)
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
private void OnTimerUp()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
public override void Destroy()
|
|
{
|
|
_timer.Destroy();
|
|
base.Destroy();
|
|
}
|
|
}
|
|
}
|