Hi there,
I changed normalizedPosition value by code when I’m dragging scrollrect (not release finger), but scroll delta doesn’t change, so scrollview come back to before normalizedPosition changed when I keep dragging (still not release finger). Someone help.
ScrollRect uses current mouse position - start mouse position to update/calculate normalizedposition (instead of for instance using delta or otherwise handling any updates to normalizedposition).
The source for ScrollRect in 5.1 is here:
https://bitbucket.org/Unity-Technologies/ui/src/ccb946ecc23815d1a7099aee0ed77b0cde7ff278/UnityEngine.UI/UI/Core/ScrollRect.cs?at=5.1
I have the same problem and thinking about overriding the OnDrag function where it calculates the delta (line 256 -
var pointerDelta = localCursor - m_PointerStartLocalCursor;
) to use eventData.delta instead. But havent tried if it would work as expected yet.
It worked, Thanks a lot!!!
public class Scroller : ScrollRect
{
PointerEventData m_beginEventData;
public override void OnBeginDrag(PointerEventData eventData)
{
base.OnBeginDrag(eventData);
m_beginEventData = eventData;
}
public void Reset()
{
OnBeginDrag(m_beginEventData);
}
}
Reset() after modified normalizedposition.