i couldnt find an *easy* way to retrieve the top/bottom local position of a scrollview.
any chance there is something hidden that returns these values?
hack of the SetDragAmount method:
public Vector3 GetScrollviewPosition(int x, int y)
{
// (0, 0) is the top-left corner, (1, 1) is the bottom-right.
//float x = 0;
//float y = 1;
UIPanel mPanel = scrollview.panel;
//DisableSpring();
Bounds b = scrollview.bounds;
if (b.min.x == b.max.x || b.min.y == b.max.y) return Vector3.zero;
Vector4 clip = mPanel.finalClipRegion;
float hx = clip.z * 0.5f;
float hy = clip.w * 0.5f;
float left = b.min.x + hx;
float right = b.max.x - hx;
float bottom = b.min.y + hy;
float top = b.max.y - hy;
if (mPanel.clipping == UIDrawCall.Clipping.SoftClip)
{
left -= mPanel.clipSoftness.x;
right += mPanel.clipSoftness.x;
bottom -= mPanel.clipSoftness.y;
top += mPanel.clipSoftness.y;
}
// Calculate the offset based on the scroll value
float ox = Mathf.Lerp(left, right, x);
float oy = Mathf.Lerp(top, bottom, y);
// Update the position
//if (!updateScrollbars)
//{
Vector3 pos = scrollview.transform.localPosition;
//if (canMoveHorizontally) pos.x += clip.x - ox;
pos.y += clip.y - oy;//if (canMoveVertically)
return pos;
//}
}
edit: is there a way to detect scrollbar "dragstart". there isnt a tandem event to onDragFinished... id prefer not to use uicamera for this.