[英]Unity 3d (NGUI) How to remember the last scrolled position in the NGUI ScrollView?
I have a ScrollView with loads of buttons, My question is how to make the scrollview to remember the last scrolled position even after the scene is reloaded. 我有一个带有大量按钮的ScrollView,我的问题是即使重新加载场景后,如何使scrollview记住上一个滚动位置。 In other words how to make the scroll view to remember the last viewed child so that if the scene is reloaded it should have that particular child in the center of the view.
换句话说,如何使滚动视图记住上一个查看的子项,以便重新加载场景时,该特定子项应位于视图中心。 Please ask if you can't get the question
请问您是否无法解决问题
You want to save the normalized value, scrollView.horizontalScrollBar.value
or scrollView.verticalScrollBar.value
whichever applies, to . 您想要将规范化的值
scrollView.horizontalScrollBar.value
或scrollView.verticalScrollBar.value
保存为适用。 xml
or just do a DontDestroyOnLoad(scrollView.gameObject)
xml
或只执行DontDestroyOnLoad(scrollView.gameObject)
If you use UICenterOnChild
, simply store the currently centered object (using centeredObject
) somehow (by index, by name, by whatnot), then do something like CenterOn(latestCenteredObject.transform)
when loaded. 如果使用
UICenterOnChild
,只需centeredObject
某种方式(通过索引,名称,其他方式)存储当前居中的对象(使用centeredObject
),然后在加载时执行类似CenterOn(latestCenteredObject.transform)
。
See UICenterOnChild
docs for more. 有关更多信息,请参见
UICenterOnChild
文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.