How to Display Alerts

Alerts are gameplay messages that are displayed to the player. You can show alerts to give the player feedback – for example, when updating the state of a quest.

The Dialogue System uses the dialogue UI to display alerts. More information: Alerts in the Dialogue UI.

The ways to display alerts are documented below.

In addition, you can also display alerts using Timeline Support.


In Lua / Conversations

In Lua code (or using the Dialogue Editor's Lua wizard), use the ShowAlert() function. For example:

ShowAlert("New Quest: Kill 5 Rats")

This is typically done in a dialogue entry's Script, but you can also add the Lua code to a Lua On Dialogue Event component or your own scripts.

The ShowAlert() function shows the alert right away.

Alternatively, assign a string to Variable["Alert"]. For example:

Variable["Alert"] = "New Quest: Kill 5 Rats"

At the end of conversations, the Dialogue Manager automatically checks Variable["Alert"]. If it's not blank, the dialogue UI will display the value and clear it from the variable.

You can also configure the Dialogue Manager to check Variable["Alert"] on a specified frequency during gameplay.


Alert Trigger Components

You can add any of these components to your scene to trigger alerts:


In Scripts

In your scripts, call PixelCrushers.DialogueSystem.DialogueManager.ShowAlert(). For example:

DialogueManager.ShowAlert("Gained 50 XP");

In Visual Scripts (PlayMaker, etc.)

In PlayMaker, plyGame, and other visual scripting systems, use the "Show Alert" action.


Alerts in the Dialogue UI

The Dialogue System uses the current dialogue UI to display the alert. Depending on the dialogue UI's implementation, it could flash the alert on the screen, add it to a chat window, or whatever you want.

To customize the way alerts are displayed, you can customize the dialogue UI. The default implementations let you set up a label and an optional parent panel that can contain any other controls that you want to show, including an optional continue/close button.

Alerts that are launched by setting Variable["Alert"] use the settings in Dialogue Manager > Display Settings > Subtitle Settings. The duration is the length of the alert text divided by Subtitle Chars Per Second. For example, if the alert is 90 characters long and Subtitle Chars Per Second is 30, then the duration will be 3 seconds. Alerts will always be displayed at least Min Subtitle Seconds (default is 2 seconds).


<< How to Play Barks | Components >>