Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Vunpac on March 23, 2013, 12:32:06 AM

Title: OnMouseUp interfering with OnClick
Post by: Vunpac on March 23, 2013, 12:32:06 AM
alright so basically the issue here is I have a grid of nodes and you can select one (uses OnMouseUp) and clicking anywhere unselects it. The problem here is that OnMouseUp is called even on NGUI objects.

Is there a way to have OnClick ignore OnMouseUp? or maybe have NGUI widgets block unity ray events? That way the underlying nodes would never get hit with a ray causing the OnMouseUp to activate.

Thanks.
Title: Re: OnMouseUp interfering with OnClick
Post by: ArenMook on March 23, 2013, 01:42:03 PM
OnMouseUp is a Unity event that will be deprecated in a future release of Unity. You should not rely on it. Use NGUI's OnPress(false) instead.
Title: Re: OnMouseUp interfering with OnClick
Post by: Vunpac on March 23, 2013, 02:20:35 PM
To do that I just need to add UICamera to my main camera then replace OnMouseUp with OnPress(false) and should have the same results with proper workings?

I won't have time to check today. But I thank you for your reply and I eagerly await the results once implemented.
Title: Re: OnMouseUp interfering with OnClick
Post by: Nicki on March 23, 2013, 08:33:21 PM
To do that I just need to add UICamera to my main camera then replace OnMouseUp with OnPress(false) and should have the same results with proper workings?

Yes.

void OnPress(bool pressed)
{
if (pressed == false)
{
//Same as OnMouseUp
}
}
Title: Re: OnMouseUp interfering with OnClick
Post by: Cawas on September 19, 2013, 10:42:54 AM
OnPress(false) is not same as OnMouseUp.

If I press mouse button or tap on screen outside of the collider then move into inside the collider, OnMouseUp will trigger while OnPress(false) will not.

So, other than making our own even controller, is there any way within NGUI to get a true OnMouseUp?
Title: Re: OnMouseUp interfering with OnClick
Post by: ArenMook on September 19, 2013, 04:05:07 PM
It will trigger if "sticky press"  is turned off on your UICamera.
Title: Re: OnMouseUp interfering with OnClick
Post by: Cawas on September 19, 2013, 04:07:10 PM
It will trigger if "sticky press"  is turned off on your UICamera.

Nice! But then I suppose we can't have both... Can we?
Title: Re: OnMouseUp interfering with OnClick
Post by: ArenMook on September 19, 2013, 04:09:28 PM
Both what? Try it.
Title: Re: OnMouseUp interfering with OnClick
Post by: Cawas on September 19, 2013, 04:12:48 PM
Yes, I just tried it. It works! But I was then instantly wondering... If I want some buttons with sticky and others without it (which I'm not even sure if I do need). I suppose we can make 2 cameras... Still, seems like having a OnPressUp would make more sense, but I'm not sure. Thus, I asked "can we have both". :-)
Title: Re: OnMouseUp interfering with OnClick
Post by: ArenMook on September 19, 2013, 04:13:35 PM
No you can't. It's a per-camera setting.
Title: Re: OnMouseUp interfering with OnClick
Post by: Cawas on September 19, 2013, 04:17:34 PM
Thinking about the code produced, I guess it makes more sense having them as separated events (http://www.tasharen.com/forum/index.php?topic=5846.msg27678#msg27678) (OnPressUp, OnPressDown, OnPressUpAsButton), rather than sensitive to a setting. I think it'd make it more evident: when you read it you know what it is. As it is now you'd have to know first if the camera is sticky or not.

In any case, thanks! That's quite good. ;D

NGUI is friggin' awesome. I don't say it out loud enough.