70 lines
1.5 KiB
C#
70 lines
1.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
using WI;
|
|
|
|
public class UI_CalendarItem : UIBase, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
|
{
|
|
DateTime targetDate;
|
|
|
|
public Action<DateTime> onClickEvent;
|
|
public Image HoverUI;
|
|
public Image SelectUI;
|
|
public Image TodayUI;
|
|
public TextMeshProUGUI Text_Day;
|
|
|
|
private void Init()
|
|
{
|
|
HoverUI.gameObject.SetActive(false);
|
|
SelectUI.gameObject.SetActive(false);
|
|
TodayUI.gameObject.SetActive(false);
|
|
Text_Day.text = string.Empty;
|
|
}
|
|
|
|
public void SetDate(DateTime date, Color color)
|
|
{
|
|
Init();
|
|
targetDate = date;
|
|
Text_Day.text = date.Day.ToString();
|
|
Text_Day.color = color;
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
SetActive(false);
|
|
Init();
|
|
}
|
|
|
|
public void ShowSelectUI()
|
|
{
|
|
SelectUI.gameObject.SetActive(true);
|
|
}
|
|
|
|
public void ShowTodayUI()
|
|
{
|
|
TodayUI.gameObject.SetActive(true);
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
onClickEvent?.Invoke(targetDate);
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
if (TodayUI.IsActive())
|
|
return;
|
|
|
|
HoverUI.gameObject.SetActive(true);
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
HoverUI.gameObject.SetActive(false);
|
|
}
|
|
}
|