DateScroller, DateTimeScroller, TimeScroller
Note
DateTime.TimeOfDay is not set or changed by DateScroller, but changed by DateTimeScroller.
You can use ScrollBlockResizer to display the specified amount of items according to the widget height.
DateScroller Options
Interactable
boolUser can interact with this widget.
Current Date As Default
boolDefault Date
DateTime(stringin Inspector window)
Default Date Min
DateTime(stringin Inspector window)Minimal selectable date.
Default Date Max
DateTime(stringin Inspector window)Maximum selectable date.
Format
stringFormat to parse Default Date, Default Date Min, and Default Date Max.
Independent scroll
boolIf enabled any time period changes will not change other time periods.
Years
boolDisplay years scroller.
Years Scroller
ScrollerYears Step
intYears Format
string
Months
boolDisplay moths scroller.
Months Scroller
ScrollerMonths Step
intMonths Format
string
Days
boolDisplay days scroller.
Days Scroller
ScrollerDays Step
intDays Format
string
Events
OnDateChanged
UnityEvent<DateTime>The event raised when date changed.
Arguments: selected datetime.
OnDateClick
UnityEvent<DateTime>The event raised when date setted or changed.
Arguments: selected datetime.
DateTimeScroller Options
Same settings as DateScroller with addition:
Hours
boolDisplay hours scroller.
Hours Scroller
ScrollerHours Step
intHours Format
stringUsed if AMPM disabled.
Hours AMPM Format
stringUsed if AMPM enabled.
Minutes
boolDisplay minutes scroller.
Minutes Scroller
ScrollerMinutes Step
intMinutes Format
string
Seconds
boolDisplay seconds scroller.
Seconds Scroller
ScrollerSeconds Step
intSeconds Format
string
AMPM
boolDisplay AMPM scroller.
AMPM Scroller
ScrollerAMPM Format
string
TimeScroller Options
Interactable
boolUser can interact with this widget.
Current Time As Default
boolTime Text
TimeSpan(stringin Inspector window)
Default Time Min
TimeSpan(stringin Inspector window)Minimal selectable time.
Default Time Max
TimeSpan(stringin Inspector window)Maximum selectable time.
Format
stringFormat to parse Time Text, Default Time Min, and Default Time Max.
Independent scroll
boolIf enabled any time period changes will not change other time periods.
Hours
boolDisplay hours scroller.
Hours Scroller
ScrollerHours Step
int
Minutes
boolDisplay minutes scroller.
Minutes Scroller
ScrollerMinutes Step
int
Seconds
boolDisplay seconds scroller.
Seconds Scroller
ScrollerSeconds Step
int
AMPM
boolDisplay AMPM scroller.
AMPM Scroller
Scroller
Events
OnTimeChanged
UnityEvent<TimeSpan>The event raised when time changed.
Arguments: selected time.
namespace UIWidgets.Examples
{
using UnityEngine;
/// <summary>
/// Test DateScroller.
/// </summary>
public class TestDateScroller : MonoBehaviour
{
/// <summary>
/// DateScroller.
/// </summary>
[SerializeField]
protected UIWidgets.DateBase DateScroller;
/// <summary>
/// Start this instance.
/// </summary>
protected virtual void Start()
{
DateScroller.OnDateChanged.AddListener(ProcessDate);
// change culture
DateScroller.Culture = new System.Globalization.CultureInfo("en-US");
// change calendar
DateScroller.Culture = new System.Globalization.CultureInfo("ja-JP");
DateScroller.Culture.DateTimeFormat.Calendar = new System.Globalization.JapaneseCalendar();
}
void ProcessDate(System.DateTime dt)
{
Debug.Log(dt);
}
}
}
Customization
ScrollBlock has OnItemChanged(int index, ScrollBlockItem item) event.
You can subscribe to this event to customize items depending on index or value.
selected item has
Index=0items before it have a negative index
items after it have a positive index
step of the index is
1.
public class ScrollBlockCustomization : MonoBehaviour
{
[SerializeField]
ScrollBlock YearsScrollBlock;
protected void Start()
{
YearsScrollBlock.OnItemChanged += ItemChanged;
}
protected void OnDestroy()
{
if (YearsScrollBlock != null)
{
YearsScrollBlock.OnItemChanged -= ItemChanged;
}
}
protected void ItemChanged(int index, ScrollBlockItem item)
{
item.Text.Bold = index == 0;
item.Text.fontSize = index == 0 ? 20 : 14;
}
}