Unity3D制作触屏手机滑动动效果
来源:互联网 发布:建筑软件行业 编辑:程序博客网 时间:2024/04/30 03:18
http://www.cnblogs.com/gameprogram/archive/2012/03/27/2419893.html
想要苹果或安卓那种手指滑动屏幕的效果。
这里是原文,使用的是scrollview来演示。
http://www.mindthecube.com/blog/2010/09/adding-iphone-touches-to-unitygui-scrollview
它是iphone的开发,我发一下android上的,选择里边的item还没添加进来。
using UnityEngine;using System.Collections;public class TestUI : MonoBehaviour { public Vector2 scrollPosition = Vector2.zero; public float scrollVelocity = 0f; public float timeTouchPhaseEnded = 0f; public float inertiaDuration = 0.5f; public Vector2 lastDeltaPos; // Use this for initialization void Start () { } void OnGUI() { scrollPosition = GUI.BeginScrollView(new Rect(100, 40, 600, 400), scrollPosition, new Rect(0, 0, 500, 1600), false, true); for (int i = 0; i < 32; i++) { GUI.Button(new Rect(0, i*50, 400, 50), "Button"+i); } GUI.EndScrollView(); } // Update is called once per frame void Update () { if (Input.touchCount > 0) { if (Input.GetTouch(0).phase == TouchPhase.Moved) { scrollPosition.y += Input.GetTouch(0).deltaPosition.y; lastDeltaPos = Input.GetTouch(0).deltaPosition; } else if (Input.GetTouch(0).phase == TouchPhase.Ended) { print ("End:"+lastDeltaPos.y+"|"+Input.GetTouch(0).deltaTime); if (Mathf.Abs(lastDeltaPos.y)> 20.0f) { scrollVelocity = (int)(lastDeltaPos.y * 0.5/ Input.GetTouch(0).deltaTime); print(scrollVelocity); } timeTouchPhaseEnded = Time.time; } } else { if (scrollVelocity != 0.0f) { // slow down float t = (Time.time - timeTouchPhaseEnded)/inertiaDuration; float frameVelocity = Mathf.Lerp(scrollVelocity, 0, t); scrollPosition.y += frameVelocity * Time.deltaTime; if (t >= inertiaDuration) scrollVelocity = 0; } } }}
0 0
- Unity3D制作触屏手机滑动动效果
- Unity3D制作触屏手机滑动动效果
- unity3d手机滑动效果
- unity3d手机滑动效果
- Axure制作手机UI原型之界面滑动滚动效果
- LaTeX制作动图效果
- Unity3d 触屏手机滑动事件(上下左右方向精确判断)
- 界面滑动效果的制作
- Unity3d 传送门效果制作
- Unity3D制作闪关灯效果
- Unity3D-技能CD效果制作
- 实现手机滑动翻页效果
- Axure 实现手机滑动效果
- 手机网站开发:滑动翻屏效果 jquery触摸屏滑动效果
- 手机网站开发:滑动翻屏效果 jquery触摸屏滑动效果
- JQuery在PC端实现手机触屏垂直滑动效果
- 【翻译】Unity3D车辆的滑动效果
- Axure-制作App上下滑动效果
- c++实现的cnn
- html中的特殊符号
- 关于mysql的那些事(中文,特殊字符的显示,远程访问)
- 第十二周项目1-(阅读程序4、5)
- SQL 存储过程
- Unity3D制作触屏手机滑动动效果
- 为你的水晶报表装载本地图片
- GridView多行表头创建
- 蓝牙核心技术概述(三): 蓝牙协议规范(射频、基带链路控制、链路管理)
- 【学习笔记----数据结构21-图的拓扑排序】
- IntelliJ Idea 常用快捷键列表
- x64系统的判断和x64下文件和注册表访问的重定向——补记
- 自增、自减运算符
- jni方法动态注册--C++