Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started 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.
-
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.
-
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.
-
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
}
}
-
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?
-
It will trigger if "sticky press" is turned off on your UICamera.
-
It will trigger if "sticky press" is turned off on your UICamera.
Nice! But then I suppose we can't have both... Can we?
-
Both what? Try it.
-
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". :-)
-
No you can't. It's a per-camera setting.
-
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.