Author Topic: ScrollView doesn't work as expected , needs some customization ..  (Read 3192 times)

ysrikanth2011

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile

Hi,

I have a Horizontal scrollview which has items.
The scrollview is for store characters similar to Temple Run 2, One character at a time in the page. I have 7 characters presently.

I am controlling this scrollview using two methods :
1) Swiping left and right. :
This functionality is automatically provided in NGUI , but I want to reduce the sensitivity of this . I have changed the MomentumAmount to 35 but this has some negative effect. When using on low screen devices if we swipe , the screen directly jumps from 1 to 3 or 4rth element. And on very high screen devices we have to apply  more force to move items.
 
Is there fix for this ?

2) Using two Buttons for scrolling items left and right :
I have acheived this using Scroll (delta) function in the ScrollView Class, but it is not working as expected .
 The delta value is required to be changed according to device resolution .
And also the scrollview is moving , pausing for a moment and moving again, how to overcome this.(This happens on a tablet , but works normally in the mobile device).

I have turned the DragEffect to None as I want no Effect .
Is there any method to say that only to go to next element ?





Thanks in Advance...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ScrollView doesn't work as expected , needs some customization ..
« Reply #1 on: August 07, 2014, 03:58:19 AM »
1. Momentum Amount is 35 by default, so I'm not sure what you're asking. If you want it to apply less momentum when you swipe, reduce this value.

2. Ideally you should be using UIScrollView.SetDragAmount. UIScrollView.Scroll is for the mouse scroll wheel.

Going to the next element is simple. Attach UICenterOnChild between the scroll view and items:

UIScrollView
- UICenterOnChild
-- Item 1
-- Item 2... etc

UICenterOnChild.centeredObject will tell you what it's centered on. UICenterOnChild.CenterOn lets you change this.

Alternatively, have a look at UICenterOnClick. It has the math inside that can let you move the panel to a specific position (such as your item's position) even without using UICenterOnChild.