如何在Unity中开发具有惯性的滚动视图? [英] How to develop a scrollview with inertia in Unity?

查看:336
本文介绍了如何在Unity中开发具有惯性的滚动视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Unity中开发一个滚动视图".

I want to develop a "scrollview" in Unity.

基本上,我的屏幕上有一个父游戏对象,里面有很多物品. 父游戏对象足够大,因此它超出了屏幕.

Basically I have a Parent Game Object on the screen with many items inside it. The Parent Game Object is big enough so it goes outside the screen.

我开发了一个滚动脚本,因此当用户拖动父对象时,我将其移动,看起来就像在滚动.

I developed a scrolling script so when the user drags the parent object, I move it and it looks like scrolling.

我是通过实现OnMouseDrag事件来实现的.

I did this by implementing the OnMouseDrag event.

如何计算惯性并应用惯性,以便在用户快速拖动惯性时,惯性会继续运动?

How can I calculate the inertia and apply it so when the user drags it fast, it continues to move?

推荐答案

您想要的东西,想要的效果称为动态滚动/滚动/平移.

What you want, the effect that you want, is called kinetic scroll/scrolling/panning .

这是一个包含通用算法的答案,我敢肯定考虑到该关键字,您可能会发现更多示例.

Here is an answer with a generic algorithm in it, I'm sure that with this keyword in mind you will probably find a ton more of examples.

下次当心标签时,您的第一组标签不正确,其他框架具有相同的 unity 名称.

Next time watch out for the tags, your first set of tags was incorrect, other frameworks have the same unity name .

这篇关于如何在Unity中开发具有惯性的滚动视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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