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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Close Panel when touch the screen (touch position not in panel)

Discussion in 'UGUI & TextMesh Pro' started by David James, May 5, 2015.

  1. David James

    David James

    Joined:
    Jan 29, 2015
    Posts:
    61
    I has a "setting panel" , I want close it when i touch the screen (touch position not in this panel) .
    I tried but this can't display when touch the help button .

    I think when I touch the help button I accident close this panel

    How to fix this problem?
    thanks guys !
     
  2. DrowningFish

    DrowningFish

    Joined:
    May 6, 2015
    Posts:
    12
    If you want to close the settings panel when you touch anywhere in the screen, add an event trigger on the panel and use setactive = true/false.

    I think it'll be easier to include a close button at the corner of the panel, and add event trigger to that button, so when the button is pressed, it'll close the panel.

    Is this what you're referring to?
     
    David James likes this.
  3. David James

    David James

    Joined:
    Jan 29, 2015
    Posts:
    61
    I tried Use close button but I want touch anywhere in the screen close Panel . Thank for your reply
     
  4. DrowningFish

    DrowningFish

    Joined:
    May 6, 2015
    Posts:
    12
    I see, in that case, add another panel on top of that Close Panel, add event trigger, use setactive. :)
    No problem.
     
    David James likes this.
  5. David James

    David James

    Joined:
    Jan 29, 2015
    Posts:
    61
    How to add event trigger to panel? Can you help me?
     
  6. DrowningFish

    DrowningFish

    Joined:
    May 6, 2015
    Posts:
    12
    Select the object you want to have touch event, in your case, the panel, the add component > search event trigger > at the bottom part of even trigger > click on the + icon to add a function.

    I'm not good at explaining that part, try googling it. :)
     
    David James likes this.