Moving The Selection Text Panel

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Moving The Selection Text Panel

Post by PayasoPrince »

Hello,

Rather than have the Selection Text Panel appear at the top of the screen saying "spacebar to interact" I would like it to position itself directly above the NPC I am able to interact with.

Is there an out of the box way to accomplish this?
Should I attach a script updating its position every frame?

Kind regards,
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Moving The Selection Text Panel

Post by Tony Li »

Hi,

There are two ways to do that:

1. Add a Selector Follow Target component to the same GameObject as the Selector. Make sure the Selector GameObject also has a Selector Use Standard UI Elements component. Selector Follow Target will position the main selector over the NPC in screen space.

2. Or add an instance of the Basic Standard Usable UI prefab to the NPC. (See the last part of the Interaction Tutorial.) This lets you position a world space panel exactly where you want for each NPC and customize the panel's appearance for each NPC.
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Re: Moving The Selection Text Panel

Post by PayasoPrince »

Hi, Tony

I believe I am misunderstanding.

I have added "Selector Follow Target" & "Selector Use Standard UI Elements" to the "Basic Standard UI Selector" prefab. Example:

Image

This does not appear to be working. Is this incorrect?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Moving The Selection Text Panel

Post by Tony Li »

Hi,

Add those components to the GameObject that has the Selector or Proximity Selector component -- typically the player GameObject.

The Dialogue Manager GameObject has an Instantiate Prefabs component that, by default, instantiates the Basic Standard UI Selector Elements prefab into the Dialogue Manager's Canvas.

If you use Selector Follow Target, I recommend duplicating the Basic Standard UI Selector Elements prefab and assign the duplicate to Instantiate Prefabs instead of the original. Then customize your duplicate. To get the sizing right, you can remove the Reticle In Range and Reticle Out Of Range child GameObjects, and size the Main Selector Panel's height so it just fits the Selection Text Panel.

Note: If you use the world space Basic Standard Usable UI prefab on an NPC, you don't have to do any of the above.

If you haven't watched the Interaction Tutorial yet and have a few minutes, it should clarify a lot of that.

(Also: The whole Selector / Proximity Selector system is entirely optional. It's handy, and many games use it, but if you already have your own interaction system that you prefer, you can use that instead. Just configure your interaction system to call GameObject.SendMessage("OnUse") on the interaction target.)
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Re: Moving The Selection Text Panel

Post by PayasoPrince »

Adding the components to the player resolved this. Thank you.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Moving The Selection Text Panel

Post by Tony Li »

Glad to help!
Post Reply