Scroll Rect手动滚动脚本Unity C# [英] Scroll Rect manual scrolling through script Unity C#

查看:344
本文介绍了Scroll Rect手动滚动脚本Unity C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为Unity创建一个C#脚本,以使滚动视图在按"UP"键时向上滚动,而在按"DOWN"键时向下滚动.

I want to make a C# script for Unity to make the scroll view scroll up when I press "UP" key and scroll down when I press "DOWN" key.

推荐答案

只需使用

ScrollRect.horizontalNormalizedPosition // value range (0 to 1)

ScrollRect.verticalNormalizedPosition // value range (0 to 1)

尝试在向上和向下按钮的按钮单击事件处理程序上相应地lerp这些值.

try to lerp these values accordingly on button click event handlers for up and down buttons.

或者您可以在希望这会有所帮助

这篇关于Scroll Rect手动滚动脚本Unity C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆