Author Topic: How can I drag a scroll view sideways from script?  (Read 6074 times)

alexh0101

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 30
    • View Profile
How can I drag a scroll view sideways from script?
« on: May 11, 2015, 04:20:45 PM »
I tried TweenPosition from script but when it gets called, the scroll view gets shifted, but the next cell doesn't show up in the grid (it's blank).

  1. scrollViewTween.from = new Vector3(theScrollView.transform.localPosition.x,0,0) ;
  2. scrollViewTween.to = new Vector3(theScrollView.transform.localPosition.x - cellWidth,0,0) ;
  3. scrollViewTween.PlayForward();

(This doesn't work properly)

How can I drag the scroll view to the next cell from the script?

Razhagal

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 14
    • View Profile
Re: How can I drag a scroll view sideways from script?
« Reply #1 on: May 12, 2015, 03:32:28 AM »
Do you use a grid or table inside it? Or is it just random stuff into the scroll? If it's the first case you could use UICenterOnChild and attach it to the grid/table and just tell him which element to center on.

alexh0101

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: How can I drag a scroll view sideways from script?
« Reply #2 on: May 12, 2015, 08:57:34 PM »
Hi there,

Thanks for that, it worked. I'm using a grid and this code:

  1. centerOnChildScript.CenterOn(Next_Page.transform);
  2.