I initially thought it was some kind of miss code due to my menu building on the fly, it is working perfectly for xbox gamepad and I was deploying to xbox but started to add pc supports and found that for mouse input it does trigger events from the previous button, its a total maze thing.
I started to worry when In a super simple menu it keeps happening, that simple menu is not build on the fly, static buttons. Debuggin into console I can confirm that behaviour.
Being that crazy I’m surprised this is not reported yet so this may be a particular thing of mine, like some setting or so, anyone heard of this issue before? I’ve tested to happen in 2018.2 and the 2018.3 beta7
An update into this.
following above links solved half of the issue.
On the menus built on teh fly I do build navigation only if we’re in joystick mode. That will solve callin “On Click()” events form the previous button, for whatever reason this works.
Also on the event system the default select is sect to none.
Still, when click, I’ve to double click the button for the event triggers assigned via script to be called, this is so freaking annoying…
edit: on click events set from script seem to not to work properly either… what is this mess!!
ok I’ve “fixed” this issue by following the workarounds in the above thread.
as I’ve on each “Selectable” element an script that already has OnPointerEnter & OnPointerExit events, I had just to
EventSystem.current.SetSelectedGameObject(this.gameObject); //select currently hoovered
deselect on exit:
EventSystem.current.SetSelectedGameObject(null);//deselect para evitar la movida de que se queda el último seleccionado y se trigean eventos del anterior boton
looks like this,
//mouse
public void OnPointerEnter(PointerEventData eventData)
{
menu_RollOver.Play();
StartCoroutine(ScaleUpRoutine());
EventSystem.current.SetSelectedGameObject(this.gameObject); //select currently hoovered
}
public void OnPointerExit(PointerEventData eventData)
{
StartCoroutine(ScaleDownRoutine());
EventSystem.current.SetSelectedGameObject(null);//deselect para evitar la movida de que se queda el último seleccionado y se trigean eventos del anterior boton
}
on top
you need:
IPointerEnterHandler,
IPointerExitHandler
Now it works as intended, please unity fix this freaking mess
I’ve had a similar issue with dynamically instantiated ui’s where a click registered again after mouse exit and clicking anywhere else. I was not able to find a fix. Thanks for investigating, maybe this could work for my problem too.
I thougth it was only on my dinamically instantiated ui but it happens on all UI buttons, aparently after unity 4.7. May be non dinamically instantiated buttons that have not trigers setup from script may work out of the box or if their navigation is set to none, but anyways the workaround I posted saved my *ss and it did very quick and I was seriously afraid I was not going to be able to fix that mess.