Limiting Response Menu to One Option Visible

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
alexlol
Posts: 35
Joined: Sat Nov 07, 2020 8:20 am

Limiting Response Menu to One Option Visible

Post by alexlol »

Hi all,

I'm using the Bubble Template for a response menu and would like to hide all available responses besides the one that is currently selected.

I can think of two ways of doing this: making a list of multiple buttons which disable and animate depending on player input (this is what I was doing before using DialogueSystem), or having one response button and changing its content based on player input.

Does anyone know if there is built in functionality to support something like this?
User avatar
Tony Li
Posts: 22050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Limiting Response Menu to One Option Visible

Post by Tony Li »

Nothing like that is built into the Dialogue System, and it might be better to implement a general purpose solution anyway. Here are two ideas along the lines that you suggested:

1. Set the buttons to use animation transitions. In the normal state, play an animation that sets the button's scale to (0,0,0). In the highlighted/selected state, play an animation that sets the button's scale to (1,1,1). When a button is selected, it will be normal scale. The other, non-selected buttons will shrink down to be invisible. (Or add a Canvas Group to the button and animate its Alpha if you prefer.)

2. Or put the buttons in scroll rect that's just big enough to show one button. You can grab the ScrollToMe script from the free Menu Framework package on the Dialogue System Extras page and put it on your buttons. When a button is selected, ScrollToMe will adjust the Scroll Rect's scroll position so that button is visible.

Personally, I'd go with #1. I think it will look more lively to see the buttons animated into their visible/hidden states.
alexlol
Posts: 35
Joined: Sat Nov 07, 2020 8:20 am

Re: Limiting Response Menu to One Option Visible

Post by alexlol »

Thanks, that's great advice. Option one works well - I'm hiding any button that isn't currently selected.

I'm hitting a little snag - all response buttons appear initially, before correctly disappearing when I begin navigation. My thought to solve this was simply to add a Button.Select() to my desired button in the On Open() event of the Standard UI Menu Panel component. When I do so, however, I get a NullReferenceException. Is this due to the way Dialogue System is handling the buttons?
User avatar
Tony Li
Posts: 22050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Limiting Response Menu to One Option Visible

Post by Tony Li »

Yes. You could add a Canvas Group to the menu panel. Make sure it's not controlled by the animator*. Connect a method to the OnOpen() event. In that method, set the Canvas Group's Alpha to zero (invisible). After one frame, set it to 1. This gives the UI one frame to complete its layout and set all of the buttons' animations.

*Or, if you use an animator, make sure the animator keeps the Canvas Group's Alpha at zero for at least 1 frame at the beginning.
alexlol
Posts: 35
Joined: Sat Nov 07, 2020 8:20 am

Re: Limiting Response Menu to One Option Visible

Post by alexlol »

Thank you for your time with this, sorry for all the questions.

Giving time for UI to complete its layout is working, but navigation fails when I move the position of the buttons. My aim is to place all the response buttons in the same position. If I remove the Horizontal Layout Group and position my response buttons over the top of each other (or adjust the spacing in the HLG for to achieve the same positioning), the buttons no longer navigate.

Is there a problem with overlaying buttons that in world space that makes Dialogue System's navigation unable to select them? My aim is to achieve response panel navigation similar to how it appears in something like Night In The Woods.
User avatar
Tony Li
Posts: 22050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Limiting Response Menu to One Option Visible

Post by Tony Li »

Hi,

That navigation issue probably isn't Dialogue System-specific. Buttons default to Automatic navigation. If they're on top of each other, Unity UI won't know how to automatically determine where to navigate to.

Instead, inspect each button and change the Navigation to Explicit. Then assign the left/right (or up/down) destinations for each button.
alexlol
Posts: 35
Joined: Sat Nov 07, 2020 8:20 am

Re: Limiting Response Menu to One Option Visible

Post by alexlol »

That has worked, thank you! Sorry, as I'm new to Unity I'm not always sure what problems are specific to Dialogue System or just the engine.
User avatar
Tony Li
Posts: 22050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Limiting Response Menu to One Option Visible

Post by Tony Li »

No worries; glad to help!
Post Reply