Search Unity

Make Sure A Button Doesn't Get Deselected

Discussion in 'UGUI & TextMesh Pro' started by HappySlice, May 6, 2015.

  1. HappySlice

    HappySlice

    Joined:
    Nov 3, 2014
    Posts:
    22
    I have a game that uses a gamepad as the primary input. If the user accidently touches the mouse it can deselect the highlighted button and then the user has to close out of the game to navigate through the menus again.

    How do I make it so a button is always selected?
     
  2. DrowningFish

    DrowningFish

    Joined:
    May 6, 2015
    Posts:
    12
    Assuming the accidental touch of your mouse doesn't collide with anything, you can try this:

    Put the select highlight function under void OnTrigger instead of update.

    So it'll looks like:
    You're using gamepad to select a button and your mouse is somewhere outside, when you accidentally touches the mouse and if the mouse cursor doesn't collide with anything, nothing will happen, unless your mouse touches the button, the button will get highlighted.

    Hope this is what you're referring to, I don't quite get the question. o_O