Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Case 1096728 Ui Input click triggers previous buttons events

Discussion in '2018.3 Beta' started by TooManySugar, Oct 31, 2018.

  1. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I'm facing a crazy situation,

    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
     
  2. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I've stripped repro project ready
    I'll upload as soon as I can

    edit: uploaded Case 1096728
     
    Last edited: Nov 1, 2018
  3. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
  4. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    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!!
     
    Last edited: Nov 1, 2018
  5. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    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,

    Code (CSharp):
    1.    //mouse
    2.     public void OnPointerEnter(PointerEventData eventData)
    3.     {
    4.          menu_RollOver.Play();
    5.          StartCoroutine(ScaleUpRoutine());
    6.         EventSystem.current.SetSelectedGameObject(this.gameObject); //select currently hoovered
    7.     }
    8.  
    9.  
    10.     public void OnPointerExit(PointerEventData eventData)
    11.     {
    12.          StartCoroutine(ScaleDownRoutine());
    13.         EventSystem.current.SetSelectedGameObject(null);//deselect para evitar la movida de que se queda el último seleccionado y se trigean eventos del anterior boton
    14.  
    15.     }
    on top
    you need:
    Code (CSharp):
    1.     IPointerEnterHandler,
    2.     IPointerExitHandler
    Now it works as intended, please unity fix this freaking mess
     
  6. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    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.
     
  7. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    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.
     
    Flavelius likes this.