Logo
UI Elements

Calendar

A flexible date selection component

Overview

Calendar displays a full monthly view with selectable days, month and year dropdowns, optional Today highlighting, minimum and maximum date limits, and customizable initial date modes. It supports callbacks when a date is selected and exposes several control methods for programmatic navigation.

Preview


Properties

Settings

NameTypeDescription
highlightTodayboolHighlights today's date if enabled
yearRangeFromCurrentintHow many years before and after current year to include in the dropdown
initialDateModeInitialDateModeNone, Today, or Custom
customYearintYear used only in Custom mode
customMonthintMonth used only in Custom mode
customDayintDay used only in Custom mode

References

NameTypeDescription
dateLabelTMP_TextDisplays the current month and year
monthDropdownDropdownDropdown for month selection (optional)
yearDropdownDropdownDropdown for year selection (optional)
previousMonthButtonButtonNavigates to previous month
nextMonthButtonButtonNavigates to next month
daysContainerTransformParent for generated day buttons
dayButtonPrefabGameObjectPrefab with CalendarDay component

Events

NameTypeDescription
onDateSelectedUnityEvent<DateTime>Triggered when a new date is selected

Public Methods

NameParametersDescription
GetSelectedDate()NoneReturns the currently selected date (nullable)
SelectDate(date)DateTimeSelects a date and updates display
ClearSelection()NoneRemoves selection highlight
GoToToday()NoneMoves view to today's month
SelectToday()NoneSelects today's date
SetMinDate(date)DateTimeChanges minimum selectable date
SetMaxDate(date)DateTimeChanges maximum selectable date
SetYearRange(range)intRebuilds year dropdown using new range

Code Example

CalendarExample.cs
using UnityEngine;
using Evo.UI;

public class CalendarExample : MonoBehaviour
{
    public Calendar calendar;

    void Start()
    {
        // Listen to selection changes
        calendar.onDateSelected.AddListener(date =>
        {
            Debug.Log("Selected date: " + date.ToShortDateString());
        });

        // Change limits
        calendar.SetMinDate(new System.DateTime(2000, 1, 1));
        calendar.SetMaxDate(new System.DateTime(2050, 12, 31));

        // Go to today
        calendar.GoToToday();

        // Select today
        calendar.SelectToday();
    }
}

On this page