2D images

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
WTFosaurus
Posts: 2
Joined: Fri May 17, 2019 4:47 pm

2D images

Post by WTFosaurus »

Hi new to unity and have very little experience coding. I'm trying to make a game and was recommended the dialog system. I started playing around with it and adding the variables and dialogue I needed was pretty easy.

What would be the simplest method of adding a 2D image jpeg/png or gif during a conversation that stays there until replaced later in the conversation?
I need it to display over any other elements except the UI and Dialogue.

Thanks for any help you can provide me!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2D images

Post by Tony Li »

Hi,

Welcome to Unity and the Dialogue System!

The easiest way is to add the image to your scene as a child of an active GameObject, and deactivate it. In the screenshot below, the active GameObject is named Images, and it has some inactive image GameObjects named Duck, Pig, and Cow.

To activate the Duck in a dialogue entry node, set the Sequence field to:

Code: Select all

{{default}};
SetActive(Duck,true)
You can type this manually, or you can do it all with a mouse using these steps:

1. On the right-hand side of the Sequence field, click "+" > Include Dialogue Manager's Default Sequence.

2. Drag the Duck from the Hierarchy into the Sequence field.
setActive.png
setActive.png (65.17 KiB) Viewed 255 times
If you want to later hide the Duck and show the Cow, use these commands in the Sequence field:

Code: Select all

{{default}};
SetActive(Duck,false);
SetActive(Cow,true)
WTFosaurus
Posts: 2
Joined: Fri May 17, 2019 4:47 pm

Re: 2D images

Post by WTFosaurus »

Awesome! Thanks for the quick reply. Your instructions were super easy to follow and I added the images I wanted to trigger during my test conversation very easily. Ran into a problem because I didn't know how to set an object to inactive to start. Initially got around it by listing a bunch of SetActive(fixed.Open_Image2,false); for each image in the conversation on the first node of the conversation.

Finally figured out that all I had to do was to hit that little check box in the inspector for each image to set starting state to inactive.

Thanks for the help!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: 2D images

Post by Tony Li »

Glad to help! :-)
Post Reply