Welcome,
Guest
. Please
login
or
register
.
April 27, 2026, 07:46:43 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
[Solved] How to catch a click outside of a collider?
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Solved] How to catch a click outside of a collider? (Read 3801 times)
Kerozard
Newbie
Thank You
-Given: 2
-Receive: 0
Posts: 17
[Solved] How to catch a click outside of a collider?
«
on:
August 07, 2014, 02:54:52 AM »
I am trying to create some kind of a tabbed display (the filter window in the screenshot). I want to hide it if the user clicks somewhere outside the filter window so i tried using
void
OnSelect
(
bool
isSelected
)
{
if
(
!
isSelected
)
{
Manager
.
View
.
FadeOut
(
this
.
gameObject
, 0
.
2f
)
;
}
}
The problem are the child elements that also have colliders. clicking on one of them sends an OnSelect(false) to the window itself and it gets hidden. I don't really want to go down the route of keeping track of all the window states and comparing them to mouse positions. there has to be an easier way. I was thinking about using UICamera.fallThrough but that way I could only hide it when the click event is not caught by any other object.
Any ideas how to get the desired functionality?
«
Last Edit: August 07, 2014, 04:51:09 AM by Kerozard
»
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: How to catch a click outside of a collider?
«
Reply #1 on:
August 07, 2014, 04:09:40 AM »
Set a UICamera.genericEventHandler. When you click on something, check -- is it still a part of your window's hierarchy? If so, do nothing. If no, hide it.
Logged
Kerozard
Newbie
Thank You
-Given: 2
-Receive: 0
Posts: 17
Re: How to catch a click outside of a collider?
«
Reply #2 on:
August 07, 2014, 04:27:28 AM »
I was just composing a reply that this was the solution I came up with by scouring your forum.
But thank you for your timely response. The only thing I don't like about it is, that I set the EventListener when the user clicks on the filter button. But since the button itself is not part of the filter window hierarchy, it gets hidden again right away. I am now invoking the listener with a 0.1 second delay and I don't feel that is a very elegant solution.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
[Solved] How to catch a click outside of a collider?