Page 1 of 1

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

Posted: Sun Dec 26, 2021 10:31 am
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?

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

Posted: Sun Dec 26, 2021 2:39 pm
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");