- Home /
Bug with unity scroll rect and mouse down
Hello,
I've set up a scroll rect similar to the one that is in this tutorial: https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-scroll-rect
Everything works as expected from the video.
I've now added a script that decrements the y position of the "draggable" RectTransform every second. This is a fixed amount ie) 200 pixels. This also works great - I can see the "draggable" area of that RectTransform move toward the bottom of the screen every second.
Now, if I click to move the the RectTransform up the screen, and then release the mouse before the second is up, the RectTransform moves up from its current position and then snaps down as expected. I can essentially keep sliding it back up the screen if I wish to.
However, if I click to drag and keep holding while the decrement happens, the RectTransform jumps down the expected increment for a frame and then snaps back to where it was previously (where it's currently being held by having the mouse down).
Has anyone else run into this behavior? Anyone have any ideas on how to get around this?
Thanks!
I'll have to post it later tonight. Don't have it with me at the moment.
Just add boolean isDragging and if its True ignore that metod to change y
I'm having some trouble posting my code. I pasted it in, and then hit the 101 010 button, but its still telling me that I have too many characters. I was looking at suggestion here, but it doesn't seem to work for me..
http://answers.unity3d.com/questions/149588/how-do-you-format-scripts-in-unityanswers.html
Hey Raf,
I need to change the y value of the rect transform. I need the rect transform to not pop back once I start dragging again. I believe this problem is directly tied to dragging the mouse on a scroll rect and not my code. I believe this is true because I can slide the rect transform about before the update, hold the mouse still during the update, and then as soon as I start dragging the mouse again, the rect transform pops ($$anonymous$$y code does not update the rect transform anywhere outside the update). Does this make sense? Perhaps I can disable the drag event during the update, and then reenable it once the update is complete?