Page 2 of 4

Re: How to add image in dialogue

Posted: Mon May 02, 2016 2:01 pm
by Tony Li
Can you please post 2 screenshots: your dialogue UI's hierarchy, and the inspector view of your UnityUIDialogueUI.

Re: How to add image in dialogue

Posted: Mon May 02, 2016 2:18 pm
by supadupa64
ui.jpg
ui.jpg (166.58 KiB) Viewed 1976 times

Re: How to add image in dialogue

Posted: Mon May 02, 2016 2:55 pm
by supadupa64

Re: How to add image in dialogue

Posted: Mon May 02, 2016 3:03 pm
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.

Re: How to add image in dialogue

Posted: Mon May 02, 2016 3:27 pm
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.

Re: How to add image in dialogue

Posted: Mon May 02, 2016 3:40 pm
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.

Re: How to add image in dialogue

Posted: Mon May 02, 2016 4:49 pm
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?

Re: How to add image in dialogue

Posted: Mon May 02, 2016 4:56 pm
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.

Re: How to add image in dialogue

Posted: Mon May 02, 2016 6:26 pm
by supadupa64
Alright good, because I just built a game to test it out and the little window was nowhere to be found. :shock:

Re: How to add image in dialogue

Posted: Mon May 02, 2016 9:28 pm
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().