Page 1 of 1

Animated image before Responce Button Template

Posted: Fri Feb 17, 2023 9:26 am
by Fitbie
Hi Tony and everyone!
In my Dialogue UI, I would like to have an animated "selector" picture in front of the Responce Button. It would show the current option to select. But the problem is that I use Input Device Manager and the dialogue ui in my game are controlled by both mouse and keyboard. Which means the button can be highlighted, can be selected, and so on. I was thinking of using the button component, but I already use it to change the color of the text when selecting. Make animations - each button will have an animator, which (it seems to me) is not good. Maybe you can write a script that will check if the button is not in the normal state (that is, it is either selected or highlighted) - will activate the game object? Or maybe there's an even more delicate way to put a picture to the text? Maybe there's a way to link the picture and the text? Or some built-in dialogue system script that i couldnt find yet?

So, I would like to know what you would do in my situation? Thank you!
Example below
Image

Re: Animated image before Responce Button Template

Posted: Fri Feb 17, 2023 9:47 am
by Fitbie
UPD: using 'color tint' in the button component seems the best solution, when the spiral is selected or highlighted - it becomes opaque and vice versa (on the spiral itself I have attached a script where in the Update is the method transform.rotate, i hope it doesn't affect perfomance)
But I still want to affect the text component and change its color when interacting with it, and I can't have 2 buttons components on 1 object

Re: Animated image before Responce Button Template

Posted: Fri Feb 17, 2023 9:52 am
by Tony Li
I recommend configuring the Button's Transition to use Animator, and handling this through an animator controller on the button. It's precisely what Transition -> Animator is designed for.

Also, add DeselectPreviousOnPointerEnter components to your response button(s). This prevents Unity UI for show two buttons in the selected state at the same time, which can happen if one button is selected for key/joystick navigation and you hover the mouse over a different button.