[英]Scroll to the object in my NGUI ScrollView with c#
I am trying to create a chat and it works ok except when there are more posts than can fit in the view. 我正在尝试创建一个聊天,它可以正常工作,除非发布的帖子过多,无法容纳该视图。 So when I open the scrollview it always start at the top, but the latest chat is at the bottom and I should be starting there.
因此,当我打开滚动视图时,它总是从顶部开始,但是最新的聊天在底部,因此我应该从那里开始。 I have the same problem when I add an post it instantiates below my viewport?!?
添加帖子实例化到视口下方时,我也遇到同样的问题? How do I solve this?
我该如何解决?
I am trying to do so with a SpringPanel but am having a hard time figuring out what to put into it? 我正在尝试使用SpringPanel这样做,但是很难弄清楚要放入什么?
SpringPanel mySpringPanel.Begin(GameObject go, Vector3 pos, float strength)
I know the strength and the Vector3 should be something like(0,MyLatsObject,0) but what is the gameobject and again... How do I figure out the Vector3? 我知道强度和Vector3应该是类似(0,MyLatsObject,0)的东西,但是游戏对象又是什么……我该如何计算Vector3?
Hope this makes sense and any help is appreciated. 希望这是有道理的,感谢您的帮助。
Thanks in advance :-) 提前致谢 :-)
You need to use the CentreOnChild script. 您需要使用CentreOnChild脚本。 With it you can call
UICenterOnChild.CenterOn(Transform target)
to centre the scrollview on the gameObject you want. 有了它,您可以调用
UICenterOnChild.CenterOn(Transform target)
以将滚动视图居中于所需的gameObject上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.