/// <summary>
        /// Shows an alert dialog with 1 button.
        /// </summary>
        /// <returns>The one button alert.</returns>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</param>
        /// <param name="button">Button.</param>
        internal static MobileNativeAlert ShowOneButtonAlert(string title, string message, string button)
        {
            #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.ShowOneButtonAlert(title, message, button);
            #elif UNITY_ANDROID
            AndroidNativeAlert.ShowOneButtonAlert(title, message, button);
            #endif

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

            return(null);
            #endif
        }
Example #2
0
            /// <summary>
            /// Shows an alert dialog with 1 button.
            /// </summary>
            /// <returns>The one button alert.</returns>
            /// <param name="title">Title.</param>
            /// <param name="message">Message.</param>
            /// <param name="button">Button.</param>
            internal static AlertPopup ShowOneButtonAlert(string title, string message, string button)
            {
                #if UNITY_EDITOR
                Debug.Log("Show 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 alert
                iOSNativeAlert.ShowOneButtonAlert(title, message, button);

                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 alert
                AndroidNativeAlert.ShowOneButtonAlert(title, message, button);

                return(Instance);
                #else
                Debug.Log("Native alert is not supported on this platform.");
                return(null);
                #endif
            }