/// <summary>
        /// Shows an alert dialog with 2 buttons.
        /// </summary>
        /// <returns>The two buttons alert.</returns>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</param>
        /// <param name="button1">Button1.</param>
        /// <param name="button2">Button2.</param>
        internal static MobileNativeAlert ShowTwoButtonAlert(string title, string message, string button1, string button2)
        {
            #if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR
            if (Instance != null)
            {
                return(null);    // only allow one alert at a time
            }
            // Create a Unity game object to receive messages from native side
            Instance = new GameObject(ALERT_GAMEOBJECT).AddComponent <MobileNativeAlert>();

            // Show the native platform-specific alert
            #if UNITY_IOS
            iOSNativeAlert.ShowTwoButtonsAlert(title, message, button1, button2);
            #elif UNITY_ANDROID
            AndroidNativeAlert.ShowTwoButtonsAlert(title, message, button1, button2);
            #endif

            return(Instance);
            #else
            // Platform not supported
            if (Debug.isDebugBuild)
            {
                Debug.Log("Show 2-button alert with message: " + message);
            }

            return(null);
            #endif
        }
Exemplo n.º 2
0
            /// <summary>
            /// Shows an alert dialog with 2 buttons.
            /// </summary>
            /// <returns>The two buttons alert.</returns>
            /// <param name="title">Title.</param>
            /// <param name="message">Message.</param>
            /// <param name="button1">Button1.</param>
            /// <param name="button2">Button2.</param>
            internal static AlertPopup ShowTwoButtonAlert(string title, string message, string button1, string button2)
            {
                #if UNITY_EDITOR
                Debug.Log("Show 2-button alert with message: " + message);
                return(null);
                #elif UNITY_IOS
                if (Instance != null)
                {
                    return(null);    // only allow one alert at a time
                }
                // Create a Unity game object to receive messages from native side
                Instance = new GameObject(ALERT_GAMEOBJECT).AddComponent <AlertPopup>();

                // Show iOS 2-button alert
                iOSNativeAlert.ShowTwoButtonsAlert(title, message, button1, button2);

                return(Instance);
                #elif UNITY_ANDROID
                if (Instance != null)
                {
                    return(null); // only allow one alert at a time
                }
                // Create a Unity game object to receive messages from native side
                Instance = new GameObject(ALERT_GAMEOBJECT).AddComponent <AlertPopup>();

                // Show Android 2-button alert
                AndroidNativeAlert.ShowTwoButtonsAlert(title, message, button1, button2);

                return(Instance);
                #else
                Debug.Log("Native alert is not supported on this platform.");
                return(null);
                #endif
            }
Exemplo n.º 3
0
 /// <summary>
 /// Shows a toast message (Android only).
 /// </summary>
 /// <param name="message">Message.</param>
 /// <param name="isLongToast">If set to <c>true</c> use long length toast, otherwise use short length toast.</param>
 internal static void ShowToast(string message, bool isLongToast = false)
 {
     #if UNITY_ANDROID && !UNITY_EDITOR
     AndroidNativeAlert.ShowToast(message, isLongToast);
     #else
     Debug.Log("Toasts are only available on Android devices.");
     #endif
 }
 /// <summary>
 /// Shows a toast message (Android only).
 /// </summary>
 /// <param name="message">Message.</param>
 internal static void ShowToast(string message)
 {
     AndroidNativeAlert.ShowToast(message);
 }