Objectives 2: Pop-ups

In the last tutorial, we created an Objective with multiple states, and showed how to bring up the default Objectives menu to display it. In this tutorial, we'll create a pop-up window that informs the player when an Objective has been updated.

This pop-up will be a Menu. In the Menu Manager, create a new Menu and name it "Objective popup". Set its Appear type to Manual, and create a new Label element. Set the styling options to suit, but here we've just gone with a simple black box in the upper-right corner:

If you wish, you can use Unity UI for your styling. For simplicity though, we've kept the Source as Adventure Creator and added some simple styling:

We now want to display this Menu, with some dynamic text, whenever an Objective is updated. To do this, we'll make use of the Events Editor to run an ActionList at this time.

The Events Editor can be accessed from the top toolbar, under Adventure Creator -> Editors -> Events Editor:

From the New event field, select Objective: Update and click the + icon to create a new event.

Leave the fields as their default values, and then click the + icon beside the ActionList when trigger field. This will create a new ActionList asset file named OnObjectiveUpdate. Notice the Parameters box that now appears below: the asset's Objective parameter will be set to the Objective that is being updated.

By default, this event will run any time an Objective is updated. If we want to limit it to only new Objectives, or completed/failed ones, we can specify this in the State condition field.

Locate this new asset file, and double-click it to open it.

Before we show the Menu, we'll first amend the Label element so that it displays the name of the updated Objective. To do this, we'll use the Menu: Update content Action. Set the Menu and Element names to match the Menu we've just created:

For the New label field, we could set this to the Objective name directly by selecting the Objective parameter from the dropdown list. However, we can also use text tokens to combine this parameter's label with the words "Objective updated: " before it. For this, we'll want the [paramlabel:X token, where X is the ID of the parameter (0 in this case). Using this, set the Action's New label field to Objective updated: [paramlabel:0]:

Details on available tokens in text boxes can be found in the Manual's 'Text tokens' chapter.

Next, we'll turn the "Objective popup" Menu on, wait a few seconds, and then turn it off again:

Finally, we'll have the ActionList run in the background so that it doesn't interfere with gameplay. This can be set via the When running field in the Properties tab:

Now, whenever an Objective is updated - which can be done with the Objective: Set state Action, the player will be notified: