How to add image in dialogue

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

Re: How to add image in dialogue

Post by Tony Li »

Can you please post 2 screenshots: your dialogue UI's hierarchy, and the inspector view of your UnityUIDialogueUI.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: How to add image in dialogue

Post by supadupa64 »

ui.jpg
ui.jpg (166.58 KiB) Viewed 2104 times
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add image in dialogue

Post by Tony Li »

Thanks for the screenshots. Okay, you're using UnityDialogueUI (legacy Unity GUI). These steps should do it:

1. Inspect the "Dialogue Window" GameObject.

2. Then select menu item GameObject > Create Other > Dialogue System > Unity GUI > Image. This will create a GUIImage that's a child of the Dialogue Window.

3. Assign your render texture to Image > Texture so you can see its contents. You may also need to fiddle with Image > Pixel Rect.

4. Adjust the Scaled Rect parameters to get the size and position you want. I recommend settings like the ones below. For this example, let's say the image is 128x128 pixels.
  • Origin: BottomRight
  • Alignment: BottomRight
  • X: -188, Pixel
  • Y: -256, Pixel
  • Width: 128, Pixel
  • Height: 128, Pixel
5. Give the GUI Image GameObject a unique name that you can use in your SetActive() sequencer commands.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: How to add image in dialogue

Post by supadupa64 »

I'm trying this but I'm not sure what this is supposed to do. I have a camera with a 3D object. It looks like the GUIimage only shows 2d texture image.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add image in dialogue

Post by Tony Li »

Right-click in the Project view and select Create > Render Texture.

Then assign the render texture asset to your camera's Texture Target field and to the GUI Image's Image > Texture field.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: How to add image in dialogue

Post by supadupa64 »

Well, I couldn't get it to work, but in the mean time I figured out that I really didn't want it showing over the top and it looked better off to the side. I'm not sure it's set up correctly, but it looks like it sorta works. When I scale the screen, the image stays in one place horizontally, but if I move the screen vertical it moves.

Is there a way to lock the position?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add image in dialogue

Post by Tony Li »

I'll put together an example scene today that uses a RenderTexture. I'll position it on the dialogue UI, but you'll be able to reposition it wherever you want.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: How to add image in dialogue

Post by supadupa64 »

Alright good, because I just built a game to test it out and the little window was nowhere to be found. :shock:
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add image in dialogue

Post by Tony Li »

Here's an example: UnityDialogueUIRenderTexture_2016-05-02.unitypackage

It required a little script because I had forgotten that GUIImage accepts a Texture2D, and a RenderTexture is a Texture (not a Texture2D). The example scene is just the Feature Demo, except it uses the Necromancer GUI and shows a render texture of the computer terminal. It doesn't show or hide the render texture, but you can do that on your own using SetActive().
Post Reply