Messages

It's common in tutorials to display messages in different shapes and forms to inform the players of the things they should know or do.

Quick Start

You can kick off using numerous prefabs shipped with the asset pack. You can find these prefabs at Assets/TutorialMAX/Prefabs/Messages. These include popups and tooltips. You can easily create your own message presenters though.

Tooltips

There's an extra layer of components written on top of the messaging for tooltips. These components are designed to display messages in a tooltip-like fashion.

To add the tooltip support to a message, all you need to do is to click on "Add Behavior" and select "Tooltip". This will result in the creation of a Tooltip component.

Displaying Messages

If you've already created your message presenter component or grabbed a pre-made one from the prefabs folder, you can directly display a message - if it is not tooltip - using the Set Message state behavior. You could use a Manual Behavior Group for convenience.

To display a tooltip, add the Show Tooltip component to any object with determinable bounds.

Creating Message Presenters

The starting point for creating any message presenter is the TutorialMessage component. You can create it by right clicking on the hierarchy window, and then selecting TutorialMAX => Messaging => Message.

There are two parts to each message:

  1. Bounds: This is the area where the message will be displayed.
  2. Content: This is the actual message to be displayed. It can be text, a GameObject already in the scene, or a prefab.

1. Handling Bounds

To move and resize the message on Canvas, you can use the RectTransform Handler component. Simply click on "Add Behavior" and select UI => RectTransform Handler.

2. Presenting Content

To present text on a TextMeshProUGUI component, click on "Add Behavior" and select UI => Text Presenter.
To present any GameObject which is used for custom content, click on "Add Behavior" and select Object Content Presenter.
You'd typically want to have both components defined on your message.

3. Configure Pipelines

You typically want to configure the pipelines for the text and the bounds.

4. Configuring Appearance/Disappearance

To make the message fade in and out accordingly, you can add a Canvas Group to the root GameObject of the message. Then click on "New Behavior Group", select Visibility and check "Is True". Then click on "Add Behavior" and select UI => Canvas Group Alpha.

5. (opt.) Add Tooltip

If you're creating a presenter for tooltip messages, click on "Add Behavior" and select "Tooltip".