Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Ana on December 29, 2013, 09:14:05 AM
-
I've run riecently into a bug and wanted to point it (and the fix) out in case anyone else runs into the same problem in the future.
I have an image that has UIDragObject attached and everything works great. However, I had a need to disable that script and then enable it again in the future.
When I enable it again, the last touch position the script registered is way different that the new touch position and that causes the script to offset the image by a great amount even though you just touched it and haven't really dragged it around.
It took me half an hour to get into it and figure what was causing the problem. A simple solution is to add this to the UIDragObject script:
void OnDisable()
{
mStarted = false;
}
That way first touch after the next enable will be treated as such, and the previously remembered touch will not be taken into account.
I'm not up to date with current NGUI so I don't know if it has been fixed, but I am pointing it out just in case it hasn't.
-
Are you disabling the object while it's being dragged? I see no other way why this would not get set to 'false' for you in OnPress(false).
-
No, not the object, I am disabling the script but for all intents and purposes it doesn't make a difference.
I am disabling the script when the user starts pinching so another non ngui script can do the pinch scaling. And then when the user stops pinching it is enabled again so the object can be dragged around. (this wouldn't be needed if NGUI had support for multitouch gestures, but it doesn't)
-
Same thing though. Script gets disabled, so it has no way of receiving the OnPress(false) notification. I've added your change in 3.0.8 f2 btw.
-
Same thing though. Script gets disabled, so it has no way of receiving the OnPress(false) notification.
That's why I said it doesn't make a difference.
I've added your change in 3.0.8 f2 btw.
Thank you.