Hi there,
We recently upgraded our project from 5.6.1 to 2017.3.1p1. Ours is a very UI-heavy project, that relies a lot on ScrollRect’s functionality.
We have a class that inherits from ScrollRect. In Update(), it sets horizontalNormalizedPosition to some value, then reads content.anchoredPosition back (which should be internally modified by ScrollRect when setting the horizontal norm position, so that both are in sync). Actual code:
public void Update(){
Vector2 cursorInViewport = viewport.InverseTransformPoint(cursor.position);
float navigableViewportWidth = viewport.rect.width * 0.5f - scrollMargin;
float offset = Mathf.Clamp01( ( cursorInViewport.x - navigableViewportWidth )/scrollMargin );
offset -= Mathf.Clamp01( (-cursorInViewport.x - navigableViewportWidth )/scrollMargin );
horizontalNormalizedPosition = Mathf.Max(0,horizontalNormalizedPosition + offset * scrollSpeed * Time.deltaTime);
}
We also override OnBeginDrag, OnEndDrag and OnDrag to get rid of ScrollRect’s default interaction. Scrolling is instead controlled by the position of a cursor object, relative to the scrollrect’s viewport.
This works just fine inside the editor. However once we build the standalone version (Windows or MacOS), anchoredPosition remains (0,0) no matter what.
We’re extremely confused by this behavior, specially since it worked fine in 5.5 and 5.6 (both editor and build), and works inside 2017’s editor, but does not work in the build.
We have searched the forums and the bug tracker for something similar, but could not find anything. Any hints on what is going on?