Toast.cs - UF-CSSALT/SMARTS-SDK-Unity-Asset-Package GitHub Wiki

The Toast system is used for creating alert message boxes that are only shown on the screen for a short period of time.

ToastHolder Struct

Public Fields

MonoBehaviour toastContext

The MonoBehavior object that is calling the Toast.

string toastMessage

The message that the Toast will display.

int toastDuration

The duration of the Toast in seconds.

Type toastType

Determines the type of Toast using a Type enumerator.

Gravity toastGravity

The position of the Toast on the screen.

int toastSize

The size of the Toast.

Sound toastSounds

Determines the sound of the Toast using the Sound enumerator.

string textToSpeech

If text to speech is being used this string will be spoken by the Toast when it is displayed on the screen.

Public Methods

public ToastHolder(MonoBehaviour mContext, string mMessage, int mDuration, Type mType, int mSize, Gravity mGravity, Sound mSound, string mTTS)

Public Enumerators

Type

The Type enumerator determines the type of the Toast. It has thirteen possible states:

  • ERROR
  • WARNING
  • MESSAGE
  • GREEN
  • YELLOW
  • BLUE
  • MAGENTA
  • CYAN
  • CLEAR
  • BLACK
  • WHITE
  • GREY
  • RED

Gravity

The Gravity enumerator determines the location of the Toast. It has five possible states:

  • BOTTOM
  • CENTER
  • TOP
  • TOP_RIGHT
  • BOTTOM_RIGHT

Sound

The Sound enumerator determines the sound the Toast will make when it shows up. It has five possible states:

  • NONE
  • BEEP
  • CHIME
  • WARNING
  • TEXTTOSPEECH

Static Fields

bool isActive

isActive will return the current status of the message box. True will be returned if the message box is active and false will be returned if the message box is not active.

Public Fields

bool rebuild (Inspector Only)

The rebuild button reconstructs the entire ultrasound system including scanning plane, screen resolution, and other settings to reflect runtime modifications made to fields including, but not limited to, depth, width, angle, resolution, beamThickness, etc. It destroys the previously rendered scanning plane, and rebuilds it, along with all ultrasound related textures.

Public Methods

public static void Show(MonoBehaviour caller, string message, int duration, Type type)

Creates a Toast without sound for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, int size)

Creates a Toast without sound for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Size: The size of the Toast.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, Gravity gravity)

Creates a Toast without sound for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Gravity: The position of the Toast on the screen.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, int size, Gravity gravity)

Creates a Toast without sound for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Size: The size of the Toast.
  • Gravity: The position of the Toast on the screen.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, Sound sound)

Creates a Toast with sound for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Sound: The type of sound that the Toast will produce when called.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, int size, Sound sound)

Creates a Toast with sound for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Size: The size of the Toast.
  • Sound: The type of sound that the Toast will produce when called.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, Gravity gravity, Sound sound)

Creates a Toast with sound for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Gravity: The position of the Toast on the screen.
  • Sound: The type of sound that the Toast will produce when called.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, int size, Gravity gravity, Sound sound)

Creates a Toast with sound for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Size: The size of the Toast.
  • Gravity: The position of the Toast on the screen.
  • Sound: The type of sound that the Toast will produce when called.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, string textToSpeech)

Creates a Toast with text to speech for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • TextToSpeech: The string of text that will be converted to speech and played with the Toast.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, int size, string textToSpeech)

Creates a Toast with text to speech for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Size: The size of the Toast.
  • TextToSpeech: The string of text that will be converted to speech and played with the Toast.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, Gravity gravity, string textToSpeech)

Creates a Toast with text to speech for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Gravity: The position of the Toast on the screen.
  • TextToSpeech: The string of text that will be converted to speech and played with the Toast.

public static void Show(MonoBehaviour caller, string message, int duration, Type type, int size, Gravity gravity, string textToSpeech)

Creates a Toast with text to speech for a certain duration. The method parameters are as follows:

  • Caller: The MonoBehaviour object that calls the Toast method.
  • Message: The message that will be displayed by the Toast.
  • Duration: The duration of the Toast in seconds.
  • Type: The type of the Toast.
  • Size: The size of the Toast.
  • Gravity: The position of the Toast on the screen.
  • TextToSpeech: The string of text that will be converted to speech and played with the Toast.

Private Methods

private static void NoClicked()

This method sets the message result to Result.NO, isActive to false, and destroys the message box.

Public Static Methods

public static bool Dismiss()

Dismisses the current toast and dumps the entire Toast queue. Returns true if a Toast was dismissed or false if there was no active Toast to dismiss.

public static bool DismmissNext()

Dismisses the current Toast being displayed, if any, and activateas the next Toast in the queue, if any. Returns true if there was amother Toast to show and a Toasts to dismiss or false if there is no Toast to show or no Toast to dismiss.

Private Static Methods

static IEnumerator DestroyToast()

Destroys Toast after waiting for the appropriate length of time.

private static string getGravityString(Gravity gravity)

Takes in a Gravity enumerator and returns the appropriate string version of it.