Author Topic: Automatically scroll UI Panel  (Read 3655 times)

jur_van_oerle

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Automatically scroll UI Panel
« on: April 21, 2016, 09:53:55 AM »
I have a UIPanel with a grid inside and I want to automatically scroll up or down. I used springPanel.Begin from here to accomplish this and it works! Awesome!
However, it always snaps back to the origin of the itemPanel, I suspect because it uses the localposition rather than the worldposition. I want to be able to drag the itemPanel around and then make the automatic scroll happen in that location.
As you can see here here, the UI ScrollView moves back to its origin. How can I change this?
Thanks in advance,

jur

PS when I change the position of the child, nothing happens to the locaton of the UI Panel; it stays put.
« Last Edit: April 21, 2016, 10:17:33 AM by jur_van_oerle »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Automatically scroll UI Panel
« Reply #1 on: April 21, 2016, 07:56:50 PM »
You can make a copy of the SpringPanel script and change it to use world position if you want, but I don't quite understand the issue you're describing. What snaps back to the origin? What origin? NGUI comes with several examples that use scroll views with SpringPanel being used by the center on child script. The window that contains scroll views can be moved both in the endless scroll views example and the normal scroll view example.

jur_van_oerle

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Automatically scroll UI Panel
« Reply #2 on: April 22, 2016, 02:24:29 AM »
Hi ArenMook,

thanks for your reply,
what I mean by it snaps back to its origin is: the UIPanel is located at, say position 0,0,0. I then drag the panel to location -10,0,0 and then use Springpanel.Begin() to make the UIPanel center on one of its children. The UIPanel then moves back to 0,0,0 and and at the same centers the specific child as seen in the GIF provided in my original question. So the centering works, I just want it to work from any location, instead of moving back to the location that it starts at.
I have the feeling like I just have some setting set to true where it should be false or vice versa because when I move the parent of the UIPanel, the UIPanel doesn't move along.
I have looked at some of the examples but I don't seem to find one that explains my problem in depth. Could you give the name of the example you are referring to? If it is not located in the package, some link to it?
cheers

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Automatically scroll UI Panel
« Reply #3 on: April 25, 2016, 12:14:32 PM »
They come with NGUI:

Example 7 - Scroll View (Panel)
Example 14 - Endless Scroll Views

SpringPanel.Begin animates from the current position to the target position. It doesn't keep any old positions. You likely have another tween there that resets the position.