简体   繁体   English

如何在NGUI的ScrollView中使用Button滚动对象

[英]How use Button in ScrollView in NGUI to scroll the object

I made the Scrollable View in NGUI using following tutorials Here but how can I use button to scroll the objects. 我做了滚动视图中使用NGUI以下教程在这里 ,但是我如何使用按钮来滚动对象。 Like If i click on up button it ScrollView should be up and If i click on down ScrollView should be down. 就像如果我单击向上按钮,则ScrollView应该向上,如果我单击向下,则ScrollView应该向下。

Your help will be appreciated. 您的帮助将不胜感激。 Thanks. 谢谢。

在此处输入图片说明

I just figure out how to do this. 我只是想知道如何做到这一点。

SpringPanel.Begin ( GameObject go,Vector3 pos,float strength ) 

here GameObject is NGUI gameObject such as ScrollView and pos is position what amount should scrollview move and strength is that related to speed. 这里的GameObject是NGUI游戏对象,例如ScrollView,而pos是位置,scrollview应该移动多少,而强度则与速度有关。 hope you will find useful. 希望对您有所帮助。

You can do two different things to have scrolling button, depending what do you mean. 根据您的意思,您可以做两个不同的事情来拥有滚动按钮​​。

  1. If you want to have a scroll button, you should create UIScrollBar component, which you will attach to you UIScrollView as a horizontal or vertical scroll bar. 如果要使用滚动按钮,则应创建UIScrollBar组件,该组件将作为水平或垂直滚动​​条附加到UIScrollView See NGUI examples included to the package. 请参阅包装中包含的NGUI示例。
  2. If you want to have a object on your list, which clicked will allow you to drag the UIScrollView , you should attach to this gameObject a UIDragScrollView component. 如果要在列表上有一个对象,单击该对象将允许您拖动UIScrollView ,则应将一个UIDragScrollView组件附加到此gameObject上。 It will allow you to drag-to-scroll behavior, similar to mobile list dragging experience. 它将允许您拖动到滚动行为,类似于移动列表拖动体验。 Again, such example should be included to the package. 同样,此类示例应包含在包装中。

EDIT: After your question clarification, the answer should be a bit different. 编辑:您的问题澄清后,答案应该有所不同。

You should write a script, with a reference to your UIScrollView and then you should call on it MoveRelative( Vector3 relative ) or MoveAbsolute( Vector3 absolute ) , which will move the scroll view. 您应该编写一个脚本,并带有对UIScrollView的引用,然后调用该脚本,它会移动滚动视图。MoveRelative(Vector3 relative)MoveAbsolute(Vector3 absolute)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM