Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

EventSystem losts selected

Discussion in 'UGUI & TextMesh Pro' started by atmuc, Jun 27, 2018.

  1. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,125
    I have a panel and 2 buttons on this panel. I set ButtonA as selected. when i touch or click on the empty area of the panel EventSystems resets selected. How can i prevent panel to reset selected item of EventSystem?
     
  2. FernandoHC

    FernandoHC

    Joined:
    Feb 6, 2018
    Posts:
    333
    You can do EventSystem.SetSelectedGameObject if you select an undesired object. Or you can have a custom interface to interact the way you want to.
    Lets say you click on a button, you can use the eventsystem selected to detect that, and your custom handler to have a selectables list (could be based on layers or tags) and only change the Selected gameobject if it is part of that list.
    You could also force re-selecting the last object when you click on an area you do not desire to select.
     
  3. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,125
    so I have to check and change it manually. is it right?