Usage
Native UI provides platform-native alert dialogs and date/time pickers for Unity games
Essential Kit wraps native iOS (UIKit) and Android UI components into a unified Unity interface. Essential Kit automatically initializes Native UI - no manual setup needed.
Table of Contents
Understanding Core Concepts
Native UI wraps a small set of platform widgets. Map each widget to the user journey before you start wiring code:
AlertDialog surfaces blocking decisions or confirmations. Use it for urgent notices, desructive actions, or short forms that need one or two data points.
AlertDialogStyle.ActionSheet provides iOS-style menus; it feels natural for secondary actions like sharing, saving, or discarding.
TextInputFieldOptions lets you request the appropriate keyboard, secure entry, and placeholder to guide the player.
DatePicker (and its
Date,Time,DateAndTimemodes) handles locale-aware scheduling tasks without reinventing spinners or calendars.Dialog lifecycle: Alerts and pickers suspend interaction with your scene. Always resume gameplay, timers, or animations once callbacks fire.
Import Namespaces
Alert Dialogs
Alert dialogs are modal windows that prompt users for decisions or display important information. Use AlertDialog.CreateInstance() to create dialogs with custom titles, messages, buttons, and text input fields.
Basic Alert Dialog
Create a simple dialog with title, message, and buttons:
Multi-Button Dialog
Add multiple action buttons for complex choices:
Text Input Dialog
Collect user input through native text fields:
Text Input with Options
Configure text input field behavior:
Alert Dialog Styles
Create action sheets on iOS for menu-style choices:
Date and Time Pickers
Date pickers provide native interfaces for selecting dates and times. Use DatePicker.CreateInstance() with different modes for date-only, time-only, or combined pickers.
Understanding Picker Modes
DatePicker supports three modes for different use cases:
DatePickerMode.Date:
Shows day, month, and year selection
Perfect for birthdays, event dates, and deadlines
DatePickerMode.Time:
Shows hours and minutes selection
Ideal for alarm settings and notification times
DatePickerMode.DateAndTime:
Shows both date and time selection
Best for scheduling specific moments (appointments, reminders)
Date Picker
Let users select a specific date:
Time Picker
Collect time input for alarms or reminders:
Date and Time Picker
Combined picker for precise scheduling:
Date Picker with Constraints
Restrict selectable date ranges:
Core APIs Reference
AlertDialog APIs
AlertDialog.CreateInstance(style)
Create new alert dialog instance
AlertDialog object
dialog.Title
Set or get dialog title
string property
dialog.Message
Set or get dialog message
string property
dialog.AddButton(title, callback)
Add action button
Void
dialog.AddButton(title, inputCallback)
Add button with text input callback
Void
dialog.AddCancelButton(title, callback)
Add cancel-style button
Void
dialog.AddTextInputField(options)
Add text input field
Void
dialog.Show()
Display the dialog
Void
dialog.Dismiss()
Programmatically close dialog
Void
DatePicker APIs
DatePicker.CreateInstance(mode)
Create new date picker instance
DatePicker object
picker.SetInitialDate(date)
Set initial displayed date
DatePicker (for chaining)
picker.SetMinimumDate(date)
Set earliest selectable date
DatePicker (for chaining)
picker.SetMaximumDate(date)
Set latest selectable date
DatePicker (for chaining)
picker.SetOnCloseCallback(callback)
Set result callback
DatePicker (for chaining)
picker.Show()
Display the picker
Void
Data Properties
DatePickerResult.SelectedDate
DateTime?
Selected date/time value; null when the picker is dismissed without a selection
TextInputFieldOptions
Class
Configure placeholder, keyboard, secure entry
Common Patterns
Pattern 1: Confirmation Dialog
Standard Yes/No confirmation:
Pattern 2: User Input Collection
Collect and validate user input:
Pattern 3: Tournament Scheduling
Date picker for event scheduling:
Pattern 4: Reminder Time Selection
Time picker for notifications:
Error Handling
Dialog dismissed without confirmation
Player taps outside the alert or presses system back
Treat OnCloseCallback with SelectedDate == null (or cancel button callbacks) as a no-op and keep the previous state intact.
Input validation fails
Text field callback receives empty or invalid data
Re-open a lightweight alert explaining the requirement and focus the relevant field again.
Dialogs invoked while another is active
Multiple modals launched simultaneously
Track outstanding dialogs; dismiss the existing one before showing the next to avoid stacking errors.
App backgrounded while dialog open
OS hides the alert/picker
In OnApplicationPause(false) re-check pending work and show the dialog again if the action is critical.
Advanced Configuration
Manual initialization is for advanced scenarios only. Essential Kit auto-initializes Native UI using the Essential Kit Settings asset. Only use Initialize() for runtime-generated settings.
Override settings at runtime if needed:
Use cases for manual initialization:
Custom dialog themes based on app branding
Runtime configuration from server
Environment-specific UI behaviors
For most games, configure settings in the ScriptableObject instead of manual initialization.
Related Guides
Demo scene:
Assets/Plugins/VoxelBusters/EssentialKit/Examples/Scenes/NativeUIDemo.unityUse with Utilities.OpenApplicationSettings() for permission recovery flows
Combine with Notification Services for reminder and alarm date selection
See Testing Guide to validate dialogs across platforms
Last updated
Was this helpful?