You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
971 B
41 lines
971 B
using UnityEngine; |
|
using System.Collections; |
|
using UnityEngine.UI; |
|
|
|
public class YearDropDown : MonoBehaviour { |
|
|
|
// Use this for initialization |
|
private Dropdown years; |
|
void Awake() |
|
{ |
|
years = GetComponent<Dropdown>(); |
|
setOptions(); |
|
} |
|
void Start() |
|
{ |
|
years.onValueChanged.AddListener(selectYear); |
|
} |
|
void OnDestroy() |
|
{ |
|
years.onValueChanged.RemoveListener(selectYear); |
|
} |
|
|
|
// Update is called once per frame |
|
void Update () { |
|
|
|
} |
|
private void setOptions() |
|
{ |
|
for (int i=1901;i<=2100;i++) |
|
{ |
|
years.options.Add(new Dropdown.OptionData(i+"年")); |
|
} |
|
} |
|
void selectYear(int yearIndex) |
|
{ |
|
//Debug.Log(year); |
|
var optionDate = years.options[yearIndex].text; |
|
var year = int.Parse(optionDate.Substring(0, optionDate.Length - 1)); |
|
transform.parent.parent.GetComponent<DateTimeControl>().yearChanged(year); |
|
} |
|
}
|
|
|