Author Topic: Overlapped button still works  (Read 3394 times)

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Overlapped button still works
« on: June 14, 2013, 10:22:23 AM »
Hi Guys,

I have an esc menu that pops up with multiple options. One of these options (quit game) should bring up a confirmation window asking to quit or cancel.

The problem I have is that once the confirm panel pops up, I can still click the button located under the confirmation panel!

How can I fix this?
Unity 4.5.3f
NGUI 3.7.0

yeagerj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Overlapped button still works
« Reply #1 on: June 14, 2013, 11:10:51 AM »
You should be able to just add a BoxCollider to the background image of your confirmation panel.

Or if you need to block input on the whole screen when the confirmation is showing, add a GameObject with a BoxCollider and a UIStretch component on it to your confirmation panel. The BoxCollider will block the input and the UIStretch will make it fill the screen.

Just make sure that your collider is behind the buttons and things in your confirmation panel.

in2repid

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Overlapped button still works
« Reply #2 on: June 14, 2013, 09:44:23 PM »
It seems as though something has changed in a recent build.  I'm seeing this problem, even with button widgets.  I have world elements that are being hit by the mouse behind the NGUI UI widgets when clicked, and this never happened previously.

Is there anything I can provide to help narrow down where the issue is?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Overlapped button still works
« Reply #3 on: June 15, 2013, 06:48:41 AM »
How they're being hit, for one.

The first collider visible by NGUI (your button) will stop all further events from falling through. This will only affect NGUI's events, however. OnMouse* series of events = not NGUI. Input.GetXXX = not NGUI.

in2repid

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Overlapped button still works
« Reply #4 on: June 15, 2013, 10:13:05 AM »
Interesting.  I'm not sure why the behavior used to be different, as it sounds as though what I'm doing never should have worked.

For example, I will pop up a dialog when the player finds a new item.  This dialog is a panel that contains a background, some text and images, and a button.  Prior to updating to the latest version, (I may have not updated for a couple of versions), when the player would mouseover or click the OK button on this dialog, elements in my game world would not receive OnMouse* events.  From your reaction, they always should have received the events, but this definitely was not the case.  I tried placing a collider on the panel and on the background behind the button, and this did not change the behavior.  As per your previous response, OnMouse* still falls through.

I do have to reiterate that this is definitely different :).  I hadn't opened my project for about a month, then I updated to the latest version of NGUI and Unity, and saw this behavior.  Since what I'm doing doesn't seem to be a supported scenario, I will try to find another solution.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Overlapped button still works
« Reply #5 on: June 15, 2013, 06:00:58 PM »
Instead of OnMouse, use OnHover (bool isOver).