Date Time Picker

You can use native IOS  Date Time Picker  when you want your player to pick date, time or delay.

 Following code snippet demonstrate how to show date picker:

IOSDateTimePicker.instance.Show(IOSDateTimePickerMode.Time);

You also need to specify Date Time Picker mode as Show method parameter. Mode represented as IOSDateTimePickerMode enum.

The Date Time Picker will appear in the bottom of the screen.  And will look similar to pictures bellow:

            

You can manually pre-set date without DateTimePicker UI. Following code snippet demonstrate how to do it:

public void Show(IOSDateTimePickerMode mode, DateTime dateTime);

Where mode must be IOSDateTimePickerMode.Date.

 

To find out what date was selected by user you can use 2 actions:

  • OnDateChanged - will be fired each time user selects the new date in the picker.
  • OnPickerClosed - fired when picker is closed.

 

Following snippet demonstrate how to subscribe to those actions and read selected date.

//Subscribing to actions
IOSDateTimePicker.instance.OnDateChanged += OnDateChanged;
IOSDateTimePicker.instance.OnPickerClosed += OnPickerClosed;

//Showing the Date Time Picker
IOSDateTimePicker.instance.Show(IOSDateTimePickerMode.DateAndTime);


//Getting Date result


void OnDateChanged (System.DateTime time) {
	Debug.Log("OnDateChanged: " + time.ToString());
}

void OnPickerClosed (System.DateTime time) {
	Debug.Log("OnPickerClosed: " + time.ToString());
}

API Reference

IOSDateTimePicker

public class IOSDateTimePicker : ISN_Singleton<IOSDateTimePicker>  {

	//--------------------------------------
	//  Actions
	//--------------------------------------

	public Action<DateTime> OnDateChanged = delegate {};
	public Action<DateTime> OnPickerClosed = delegate {};

	//--------------------------------------
	//  Methods
	//--------------------------------------

	/// <summary>
	/// Displays DateTimePickerUI with DateTimePicker Mode.
	///
	///<param name="mode">An object that contains the IOSDateTimePicker mode.</param>
    /// </summary>
    public void Show(IOSDateTimePickerMode mode);

	/// <summary>
	/// Displays DateTimePickerUI with DateTimePicker Mode and pre-set date.
	///
	///<param name="mode">An object that contains the IOSDateTimePicker mode</param>
	///<param name="name">An object DateTime that contains pre-set date time</param>
    /// </summary>
    public void Show(IOSDateTimePickerMode mode, DateTime dateTime);
}

IOSDateTimePickerMode

public enum IOSDateTimePickerMode  {
	Time = 1, // Displays hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. 6 | 53 | PM)
	Date = 2, // Displays month, day, and year depending on the locale setting (e.g. November | 15 | 2007)
	DateAndTime = 3, // Displays date, hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. Wed Nov 15 | 6 | 53 | PM)
	CountDownTimer = 4 // Displays hour and minute (e.g. 1 | 53)
}

Example Scenes

The full use example can be founded at the NativeIOSActionsExample example scene.