/// <summary> /// Shows the alert dialog with multiple buttons. /// </summary> /// <param name="_title">Text that appears in title bar.</param> /// <param name="_message">Descriptive text that provides more details.</param> /// <param name="_buttonsList">Title of action buttons.</param> /// <param name="_onCompletion">Calls the delegate when action button is pressed.</param> public void ShowAlertDialogWithMultipleButtons(string _title, string _message, string[] _buttonsList, AlertDialogCompletion _onCompletion) { // Cache callback string _callbackTag = CacheAlertDialogCallback(_onCompletion); // Show alert ShowAlertDialogWithMultipleButtons(_title, _message, _buttonsList, _callbackTag); }
private string CacheAlertDialogCallback (AlertDialogCompletion _newCallback) { if (_newCallback != null) { string _tag = NPBinding.Utility.GetUUID(); m_alertDialogCallbackCollection[_tag] = _newCallback; return _tag; } return string.Empty; }
private string CacheAlertDialogCallback(AlertDialogCompletion _newCallback) { if (_newCallback != null) { string _tag = NPBinding.Utility.GetUUID(); m_alertDialogCallbackCollection[_tag] = _newCallback; return(_tag); } return(string.Empty); }
private void AlertDialogClosed(string _jsonStr) { IDictionary _jsonData = JSONUtility.FromJSON(_jsonStr) as IDictionary; string _buttonPressed; string _callerTag; // Parse received data ParseAlertDialogDismissedData(_jsonData, out _buttonPressed, out _callerTag); Console.Log(Constants.kDebugTag, "[UI] Alert dialog closed, ButtonPressed=" + _buttonPressed); // Get callback AlertDialogCompletion _alertCompletionCallback = GetAlertDialogCallback(_callerTag); // Completion callback is triggered if (_alertCompletionCallback != null) { _alertCompletionCallback(_buttonPressed); } }
/// <summary> /// Shows an alert dialog with multiple buttons. /// </summary> /// <param name="_title">The string that appears in the title bar.</param> /// <param name="_message">Descriptive text that provides more details than the title.</param> /// <param name="_buttonsList">An array of string values, used as title of action buttons.</param> /// <param name="_onCompletion">Callback that will be called after operation is completed.</param> /// <example> /// The following code example demonstrates how to show alert dialog with 2 action buttons. /// <code> /// using UnityEngine; /// using System.Collections; /// using VoxelBusters.NativePlugins; /// /// public class ExampleClass : MonoBehaviour /// { /// public void ShowAlertDialog () /// { /// string[] _buttons = new string[] { /// "Ok", /// "Cancel" /// }; /// /// NPBinding.UI.ShowAlertDialogWithMultipleButtons("Test", "This is a sample message.", _buttons, OnButtonPressed); /// } /// /// private void OnButtonPressed (string _buttonPressed) /// { /// Debug.Log("Button pressed: " + _buttonPressed); /// } /// } /// </code> /// </example> public void ShowAlertDialogWithMultipleButtons(string _title, string _message, string[] _buttonsList, AlertDialogCompletion _onCompletion) { // Cache callback string _callbackTag = CacheAlertDialogCallback(_onCompletion); // Show alert ShowAlertDialogWithMultipleButtons(_title, _message, _buttonsList, _callbackTag); }
/// <summary> /// Shows an alert dialog with single button. /// </summary> /// <param name="_title">The string that appears in the title bar.</param> /// <param name="_message">Descriptive text that provides more details than the title.</param> /// <param name="_button">Title of action button.</param> /// <param name="_onCompletion">Callback that will be called after operation is completed.</param> /// <example> /// The following code example demonstrates how to show alert dialog with single button. /// <code> /// using UnityEngine; /// using System.Collections; /// using VoxelBusters.NativePlugins; /// /// public class ExampleClass : MonoBehaviour /// { /// public void ShowAlertDialog () /// { /// NPBinding.UI.ShowAlertDialogWithSingleButton("Test", "This is a sample message.", "Ok", OnButtonPressed); /// } /// /// private void OnButtonPressed (string _buttonPressed) /// { /// Debug.Log("Button pressed: " + _buttonPressed); /// } /// } /// </code> /// </example> public void ShowAlertDialogWithSingleButton(string _title, string _message, string _button, AlertDialogCompletion _onCompletion) { ShowAlertDialogWithMultipleButtons(_title, _message, new string[] { _button }, _onCompletion); }
/// <summary> /// Shows the alert dialog with single button. /// </summary> /// <param name="_title">Text that appears in title bar.</param> /// <param name="_message">Descriptive text that provides more details.</param> /// <param name="_button">Title of action button.</param> /// <param name="_onCompletion">Calls the delegate when action button is pressed.</param> public void ShowAlertDialogWithSingleButton(string _title, string _message, string _button, AlertDialogCompletion _onCompletion) { ShowAlertDialogWithMultipleButtons(_title, _message, new string[] {_button }, _onCompletion); }