Page 1 of 2
Add Cursor To Response Menu
Posted: Wed Apr 27, 2022 8:25 pm
by PayasoPrince
Hello,
I would like to add a cursor that points to the hovered response selection.
I am looking to add something just like this:
What is the best way to accomplish this?
Re: Add Cursor To Response Menu
Posted: Wed Apr 27, 2022 9:12 pm
by Tony Li
The Dialogue System Extras page has an example:
DS_ResponseButtonArrowExample_2022-04-17.unitypackage
The response button has an arrow Image next to it. The Button component's Transition changes the color of arrow. In the normal (unselected) state, the arrow's alpha color is zero (invisible). In the selected state, the arrow's color is visible.
The response button also has an Event Trigger component to play a sound when the button is selected.
Re: Add Cursor To Response Menu
Posted: Wed Apr 27, 2022 9:43 pm
by PayasoPrince
Very cool!
If I wanted to set something similar in my own prefab, is it as simple as adding an image to the Response Button Template's Button component?
Re: Add Cursor To Response Menu
Posted: Wed Apr 27, 2022 10:14 pm
by Tony Li
Yes, just like the example scene.
Re: Add Cursor To Response Menu
Posted: Wed Apr 27, 2022 10:38 pm
by PayasoPrince
Hmm, I feel like I am almost there. For some reason the option that is not hovered will not go transparent. It just goes to a different color shade. I also added a "DeselectPreviousOnPointerEnter" component.
I also noticed that when I copy and pasted your Response Panel, the button itself doesn't seem to highlight anymore. Is there a way to turn that on as well?
Re: Add Cursor To Response Menu
Posted: Wed Apr 27, 2022 10:44 pm
by Tony Li
Did you assign the arrow to the Button's Transition target graphic?
Make sure the Transition's Normal color > alpha is zero.
If you want to highlight the button background (e.g., the gray bar behind "Yes"), combine the arrow and background into a single image, and change the Transition type to
Sprite Swap.
Re: Add Cursor To Response Menu
Posted: Wed Apr 27, 2022 10:58 pm
by PayasoPrince
The issue was the Transition's Normal color alpha not being set to zero. It is working now!
In the future, if I wanted to make this more sophisticated and instantiate a game object or add an effect when an option is hovered, would this be possible?
Re: Add Cursor To Response Menu
Posted: Wed Apr 27, 2022 11:58 pm
by Tony Li
Yes. Use an
Event Trigger or add a script that implements interfaces such as
IPointerEnterHandler.
Re: Add Cursor To Response Menu
Posted: Thu Apr 28, 2022 10:49 am
by PayasoPrince
Oh. Awesome, thanks!
My last question is - I added an OnSelect()> Play.OneShot() for a sound effect like you did in your example scene. It works great. The only thing I don't like is that it plays the sound effect when the response menu is first created and the player hasn't pressed a button yet.
Is there anyway to have it not play the sound effect when the response menu is first enabled?
Re: Add Cursor To Response Menu
Posted: Thu Apr 28, 2022 10:56 am
by Tony Li
You might need to add a custom method to do that.