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
bool
User can interact with this widget.
Current Date As Default
bool
Default Date
DateTime
(string
in Inspector window)
Default Date Min
DateTime
(string
in Inspector window)Minimal selectable date.
Default Date Max
DateTime
(string
in Inspector window)Maximum selectable date.
Format
string
Format to parse Default Date, Default Date Min, and Default Date Max.
Independent scroll
bool
If enabled any time period changes will not change other time periods.
Years
bool
Display years scroller.
Years Scroller
Scroller
Years Step
int
Years Format
string
Months
bool
Display moths scroller.
Months Scroller
Scroller
Months Step
int
Months Format
string
Days
bool
Display days scroller.
Days Scroller
Scroller
Days Step
int
Days 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
bool
Display hours scroller.
Hours Scroller
Scroller
Hours Step
int
Hours Format
string
Used if AMPM disabled.
Hours AMPM Format
string
Used if AMPM enabled.
Minutes
bool
Display minutes scroller.
Minutes Scroller
Scroller
Minutes Step
int
Minutes Format
string
Seconds
bool
Display seconds scroller.
Seconds Scroller
Scroller
Seconds Step
int
Seconds Format
string
AMPM
bool
Display AMPM scroller.
AMPM Scroller
Scroller
AMPM Format
string
TimeScroller Options
Interactable
bool
User can interact with this widget.
Current Time As Default
bool
Time Text
TimeSpan
(string
in Inspector window)
Default Time Min
TimeSpan
(string
in Inspector window)Minimal selectable time.
Default Time Max
TimeSpan
(string
in Inspector window)Maximum selectable time.
Format
string
Format to parse Time Text, Default Time Min, and Default Time Max.
Independent scroll
bool
If enabled any time period changes will not change other time periods.
Hours
bool
Display hours scroller.
Hours Scroller
Scroller
Hours Step
int
Minutes
bool
Display minutes scroller.
Minutes Scroller
Scroller
Minutes Step
int
Seconds
bool
Display seconds scroller.
Seconds Scroller
Scroller
Seconds Step
int
AMPM
bool
Display 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
=0
items 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;
}
}