Regarding how to trigger a conversation by clicking on a 2d picture,

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
soilds
Posts: 1
Joined: Sun Dec 26, 2021 9:39 am

Regarding how to trigger a conversation by clicking on a 2d picture,

Post by soilds »

Hi, I bought this asset before, it looks great, but I just learned unity not long ago, and because my native language is not English, it is a little difficult to learn, now I have a question, that is, how to trigger the dialogue by clicking on the 2D picture, this example does not show the player, and the player just click on different pictures will appear different dialogue, I checked the related video, the trigger mentioned in it is through the 2D collision box. I've checked the video and the trigger is through the 2d collision box, I'd like to ask if there is any other way to trigger the conversation besides the 2d collision box. If I want to trigger the dialogue through script, for example, click on the next, is there a relevant script example as a reference?
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

Re: Regarding how to trigger a conversation by clicking on a 2d picture,

Post by Tony Li »

Hi,

You can make the 2D picture a UI Button and configure the Button's OnClick() UnityEvent to start the Dialogue System Trigger.

Here's an example scene with two pictures:

DS_2DPicturesExample_2021-12-26.unitypackage

The picture on the left has a 2D collider and uses a Selector component set to check the Mouse Position. (Remember to enable 2D support to make this work.)

The picture on the right uses a UI Button.

To trigger a conversation through script, use DialogueManager.StartConversation. Example:

Code: Select all

using PixelCrushers.DialogueSystem; // (Put this at the top of your script.)
...
DialogueManager.StartConversation("My Conversation Title");
Post Reply