How to add image in dialogue

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add image in dialogue

Post by Tony Li »

Hi,

Try PController as one word, so it matches the script filename, including Upper/lower case. Similarly for the proximity selector:

Code: Select all

SetEnabled(ProximitySelector, false, listener)
If that doesn't fix it, temporarily set the Dialogue Manager's Debug Level to Info. Then reproduce the problem. This should tell you what it thinks the listener is. Maybe it thinks the wrong object is the listener.
Xpyke
Posts: 13
Joined: Sun May 22, 2016 11:29 am

Re: How to add image in dialogue

Post by Xpyke »

That fixed, thanks for the amazing support Tony! Just another thing, is there some way to play a sequencer command after the dialogue ends? As you are exiting the dialogue? I want to deactivate the image I was using, but only when the player press the button to advance.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add image in dialogue

Post by Tony Li »

Hi,

If the last dialogue entry node is the player's response (e.g., "Goodbye."), then you can add the sequencer command to the node's Sequence field.

Otherwise, add a Start Sequence On Dialogue Event component to one of the participants, and set the Trigger to OnConversation. Then add an element to the OnEnd section, and add the sequencer command.
hicat1
Posts: 1
Joined: Wed Jul 05, 2017 7:52 pm

Re: How to add image in dialogue

Post by hicat1 »

Tony Li wrote:What kind of image?

To show actor portrait images like below:
Image
assign images to the actors in your dialogue database, and configure your dialogue UI with UI elements for portrait images. (The Unity UI Generic Dialogue UI is configured for portrait images if you want to see an example, as is the Mobile prefab shown above.)

If you want to show images inline with your text, I recommend buying TextMesh Pro. Neither Unity UI nor legacy Unity GUI have built-in support for inline images. But with TextMesh Pro you can do things like this:
Image

If you just want an image to appear on the screen, you can use the SetActive() sequencer command. Create a GameObject with an image (for example, a Unity UI Image in a Canvas) and set it inactive. Then use SetActive() to activate the GameObject at the desired time.

Hello,

I'm trying to do exactly as the image above shows (basically use small images as my character's responses). I am currently using the Dialogue Editor, but I'm a bit stuck on how to add images to the responses once I've installed Textmesh Pro.

Any help would be appreciated. Thank you.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add image in dialogue

Post by Tony Li »

Hi,

TextMesh Pro's process has changed slightly since Stephan's original video.

Stephan recorded more up-to-date instructions in this video and this video. (And coincidentally enough the example graphics in the second video are from a game that uses the Dialogue System!)

Briefly:

1. Drop your image into the project.

2. Right-click the image and select Create > TextMeshPro - Sprite Asset.

3. Create a folder Resources/Sprites. Move the sprite asset into this folder.

Then use a <sprite> tag in your Dialogue Text, such as: <sprite="assetname" name="imagename">
Sharzia
Posts: 9
Joined: Thu Nov 28, 2019 8:38 pm

Re: How to add image in dialogue

Post by Sharzia »

Hello,
I have an issue with adding image in dialogue.
Actually everything is working fine. I successfully add my image asset with TextMesh Pro, but it covers the previous dialogues entries and it's covered by the next ones.
I added an attachment to show you.
ImageOnText.jpg
ImageOnText.jpg (36.95 KiB) Viewed 1435 times
I tried to "play" with the Sprite Glyph Rect and offset things, but it doesn't seems to work.
I probably missed something somewhere, if someone knows where I need to look to fix this, please let me know :/
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add image in dialogue

Post by Tony Li »

Hi,

That looks like an issue with the sprite's dimensions in the TextMesh Pro sprite sheet (or maybe scaling?), or something else specific to the way TextMesh Pro shows in-line sprites. Try setting up a TextMeshProUGUI completely separate from the Dialogue System, and use the same text including the <sprite> tag. If this still has the same issue, check the sprite sheet. If the sprite sheet looks OK, I recommend posting on the TextMesh Pro section of the Unity forum. The developer is very responsive.

Alternatively, try using newlines so the image is on a separate line. I don't know that this will fix the problem if there's an issue with the dimensions, but it's worth a test.
Sharzia
Posts: 9
Joined: Thu Nov 28, 2019 8:38 pm

Re: How to add image in dialogue

Post by Sharzia »

Thank you for the quick reply.
I tried another image and got the same result.
My images are placed on their own dialogue node and they are scaled to be bigger, maybe it's the issue.

I can add lines after my <sprite> tag to give enough space but I'm afraid it will create more issues later :/
I succeeded to move them so they don't go on top of the previous dialogue line, but they are still covered with the choices replies.

I thought I missed some padding option with the dialogue nodes or something, so I asked here just in case.
Thank you for telling me where to look :)
I'll look more with the TextMeshPro asset.

Edit: I managed to make is better looking using the <size> tag , as the sprite size seems related to the font size set in the Dialogue UI. But now I have a huge gap after the sprite lol. :roll:
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add image in dialogue

Post by Tony Li »

It sounds like you have a handle on it now. I think it's just a matter of adjusting TMP settings. If it ends up being Dialogue System-related, let me know and I'll look into it with you.
Post Reply