unity-game-enginengui

How to set the scroll view position so as to display the new instantiated ui panel in the ui scroll view in ngui


My question is related to ui scroll view in ngui I have a set of panels in a scroll view that move horizontally. I use NGUITools.AddChild to add a new panel. I position this new panel to the end of the scroll view.

The problem is that i want to move towards the new panel that was created and placed at the end of scroll view but i am not able to find a proper solution to this issue.

I tried to move the whole grid manually but then the scroll view would move to some other place leaving the camera's view as the offset values get changed when i move the grid manually.

I tried to move the camera but the same issue occurred.

I tried using UIScrollView.ResetPosition() but this actually changed the scroll views position to the top left corner i.e the first ui panel child in scroll view.

But i want to move towards the last ui panel child in scroll view.

Is there any class available that sets the position of the scroll view to a particular panel. I want to move the panels or the camera whatever is feasible to display the panel i want to without affecting any offset values and the on drag values.

Thank you for reading.


Solution

  • You can use UICenterOnChild.CenterOn(transform target) to center the panel to a specific target: http://www.tasharen.com/ngui/docs/class_u_i_center_on_child.html