pradf
New Member
Posts: 3
|
Post by pradf on Feb 23, 2021 21:41:02 GMT
Hi,
I am trying to keep the scroller moving continuously to make it appear like a news reel. So add the following code to the update functipm"
private int dataval = 0;
public void Update()
{
if (dataval < 45920)
dataval++;
else
dataval = 0;
hScroller.JumpToDataIndex(dataval);
However the 'Scroll position' gets stuck at the highest value and does not loop through.
Can you provide any pointers on what I am doing wrong or sample scene that you have?
Thanks, PR
|
|
|
Post by echo17 on Feb 24, 2021 11:35:26 GMT
I'll need to see a working example of this to give you a good diagnosis. If you want, you can send me a simple project zipped up with steps to reproduce to the email in my signature. Please see this FAQ for more information: link
|
|
pradf
New Member
Posts: 3
|
Post by pradf on Mar 1, 2021 23:53:20 GMT
Attaching files from the demo. Also sent mail. It is nothing too crazy. Just calling jump continuously in the update function while updating index. Please let me know if this is the right way to do it or if there is a better way. Thanks, PR Attachments:04 Jump To Demo.zip (17.62 KB)
|
|
|
Post by echo17 on Mar 2, 2021 16:43:56 GMT
One way you could do this is like:
private void Update() { if (!hScroller.IsTweening) { dataval++; if (dataval > _data.Count - 1) { dataval = 0; }
hScroller.JumpToDataIndex(dataval, tweenType: TweenType.linear, tweenTime: 0.8f, loopJumpDirection: EnhancedScroller.LoopJumpDirectionEnum.Down); } }
Note that if you are using a tweenType of linear it will have a one-frame hesitation between each call to jump again. That is because the tweening is stopping, then the next frame the scroller is jumped, starting the tweening over again. Other tweenTypes will not notice this frame lag as much since they have easing in and out, whereas linear does not.
Alternatively, you could try experimenting with the jumpComplete optional parameter of JumpToDataIndex, jumping every time this method is fired. I didn't have as much success with this in my setup, but your project may work better. You'll have to watch the stack overflow since calling the jump from the jump complete will get you into an infinite recursion. There is probably a clever way to set this method up that I am not thinking of.
|
|
pradf
New Member
Posts: 3
|
Post by pradf on Mar 2, 2021 17:57:46 GMT
Awesome! That worked and looks very smooth too !!
Thank you very much.
|
|