Author Topic: Disable all the Backgound collider when the UI is enable.  (Read 2518 times)

abhaya.agrawal

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 11
    • View Profile
Disable all the Backgound collider when the UI is enable.
« on: July 25, 2015, 04:31:11 AM »
There are so many objects in my game. and all of them have the collider to detect touch. Whenever I open menu and i touch any option on that the background object also detect the touch.

what can i do to stop this.

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Disable all the Backgound collider when the UI is enable.
« Reply #1 on: July 25, 2015, 03:59:29 PM »
not sure if its the best solution - i use a "cover" uisprite that covers the entire screen.  this uisprite also has a collider that blocks all input to anything under it.  the controls you want to work with are above the "cover" and will work as intended.

you could omit the uisprite if you didnt want the "grayed out effect".

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disable all the Backgound collider when the UI is enable.
« Reply #2 on: July 27, 2015, 08:29:02 PM »
Assuming you are talking about events going through your background object that has no collider, the solution is simple: add a collider to it.

abhaya.agrawal

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Disable all the Backgound collider when the UI is enable.
« Reply #3 on: July 29, 2015, 01:54:34 AM »
@Aren : I can do that. But I want whenever any menu is there if I click on any objects which are not covered by menu, should not respond.

also when i click outside, I want that the menu should close.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disable all the Backgound collider when the UI is enable.
« Reply #4 on: July 31, 2015, 09:26:24 PM »
So... do that? :P

2 colliders. One on the window's background, one on the invisible widget covering the screen behind it (ALT+SHIFT+W, ALT+SHIFT+C). When you click on the screen collider, close the window.