40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
// Diese Hilfsklasse wird verwendet, um das Dropdown-Menü für den Tag mit der kokkekten Anzahl an Tagen für den ausgewählten Monat zu füllen.
|
|
|
|
public class FillDropdownWithDays : MonoBehaviour
|
|
{
|
|
public TMP_Dropdown dropdown;
|
|
Dictionary<int, int> daysPerMonth = new Dictionary<int, int>();
|
|
|
|
private void Awake()
|
|
{
|
|
daysPerMonth.Add(0, 31);
|
|
daysPerMonth.Add(1, 29);
|
|
daysPerMonth.Add(2, 31);
|
|
daysPerMonth.Add(3, 30);
|
|
daysPerMonth.Add(4, 31);
|
|
daysPerMonth.Add(5, 30);
|
|
daysPerMonth.Add(6, 31);
|
|
daysPerMonth.Add(7, 31);
|
|
daysPerMonth.Add(8, 30);
|
|
daysPerMonth.Add(9, 31);
|
|
daysPerMonth.Add(10, 30);
|
|
daysPerMonth.Add(11, 31);
|
|
}
|
|
public void FillDropdown(int month)
|
|
{
|
|
dropdown.ClearOptions();
|
|
|
|
List<string> days = new List<string>();
|
|
|
|
for (int i = 0; i < daysPerMonth[month]; i++)
|
|
{
|
|
days.Add((i+1).ToString());
|
|
}
|
|
dropdown.AddOptions(days);
|
|
}
|
|
}
|