Search Unity

Question UI elements are toggling automatically

Discussion in 'UGUI & TextMesh Pro' started by tleylan, Feb 21, 2023.

  1. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    621
    In a VR app I have a pop-up UI menu with buttons and a couple of check boxes. The right-hand primary button enables and disables the menu. When visible I can of course click the buttons and check a box but... (this is funny) when I toggle the UI menu closed and then open again the last element is clicked again.

    So if it was a checkbox that I turned off, when I close the menu and reopen it, it toggles it and it is on again. If the last item was a button (like Play) then it presses Play again.

    Any ideas what I've missed and/or how to stop the behavior?
     
  2. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    621
    I'm very curious why some questions get no reply at all. Has nobody seen this behavior or is is the solution so obvious? I've checked the code again and it seems that enabling the menu game object (to make it visible) is firing the events again and whatever item was selected receives the event.

    I can't seem to find any "smart" way to stop it which makes me believe (maybe) I've designed things incorrectly. Any comment at all?
     
  3. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    621
    Well I'm not holding out hope but since it is doing it similarly in another app I'll mention it again. This is a static UI menu in a VRChat world that has a toggle for sections of buttons. If I press a button then toggle the checkbox off and then toggle it on again whatever button was pressed is pressed again. It is enabling a panel of the buttons so I assume it is firing the pressed event again but how does one prevent that?