캘린더 추가
This commit is contained in:
73
Assets/Scripts/PGD/UI_CalendarItem.cs
Normal file
73
Assets/Scripts/PGD/UI_CalendarItem.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
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;
|
||||
|
||||
public void OnDisable()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user