-
大小: 30KB文件类型: .zip金币: 1下载: 0 次发布日期: 2021-05-10
- 语言: 其他
- 标签: Win7 TouchInput Unity NGUI
资源简介
这是一个完整的例子项目,里面含有NGUI3.8.2和TouchScript6.7及如何匹配这两个插件的代码。Unity的版本是UnitySetup64-5.1.0f3。绝对是汗水的成果。
代码片段和文件信息
using UnityEngine;
using System.Collections;
using Touchscript;
using Touchscript.Gestures;
public class TouchscriptNGUI : MonoBehaviour
{
UICamera uiCamera;
void Start()
{
uiCamera = Gameobject.FindobjectOfType(typeof(UICamera)) as UICamera;
// Disable standard NGUI inputs
uiCamera.useMouse = false;
uiCamera.useTouch = false;
TouchManager.Instance.TouchesBegan += TouchManagerBegan;
TouchManager.Instance.TouchesMoved += TouchManagerMoved;
TouchManager.Instance.TouchesEnded += TouchManagerEnded;
TouchManager.Instance.TouchesCancelled += TouchManagerCancelled;
}
private void TouchManagerBegan(object sender TouchEventArgs eventArgs)
{
TouchManagerChanged(sender eventArgs TouchPhase.Began);
}
private void TouchManagerMoved(object sender TouchEventArgs eventArgs)
{
TouchManagerChanged(sender eventArgs TouchPhase.Moved);
}
private void TouchManagerEnded(object sender TouchEventArgs eventArgs)
{
TouchManagerChanged(sender eventArgs TouchPhase.Ended);
}
private void TouchManagerCancelled(object sender TouchEventArgs eventArgs)
{
TouchManagerChanged(sender eventArgs TouchPhase.Canceled);
}
private void TouchManagerChanged(object sender TouchEventArgs eventArgs TouchPhase touchPhase)
{
Touchscript.TouchManager gesture = sender as Touchscript.TouchManager;
foreach (Touchscript.ITouch touchPoint in eventArgs.Touches)
{
UICamera.currentTouchID = uiCamera.allowMultiTouch ? touchPoint.Id : 1;
UICamera.currentTouch = UICamera.GetTouch(UICamera.currentTouchID);
bool pressed = (touchPhase == TouchPhase.Began) || UICamera.currentTouch.touchBegan;
bool unpressed = (touchPhase == TouchPhase.Canceled) || (touchPhase == TouchPhase.Ended);
UICamera.currentTouch.touchBegan = false;
if (pressed)
{
UICamera.currentTouch.delta = Vector2.zero;
}
else
{
UICamera.currentTouch.delta = touchPoint.PreviousPosition - touchPoint.Position;
}
UICamera.currentTouch.pos = touchPoint.Position;
UICamera.hoveredobject = UICamera.Raycast(UICamera.currentTouch.pos) ? UICamera.lastHit.collider.gameobject : UICamera.fallThrough;
if (UICamera.hoveredobject == null) UICamera.hoveredobject = UICamera.genericEventHandler;
UICamera.currentTouch.current = UICamera.hoveredobject;
UICamera.lastTouchPosition = UICamera.currentTouch.pos;
// We don‘t want to update the last camera while there is a touch happening
if (pressed) UICamera.currentTouch.pressedCam = UICamera.currentCamera;
else if (UICamera.currentTouch.pressed != null) UICamera.currentCamera = UICamera.currentTouch.pressedCam;
// Double-tap support
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-10-07 06:51 Touchsc
文件 162 2014-10-07 06:51 Touchsc
目录 0 2014-10-07 06:51 Touchsc
文件 107 2014-10-07 06:51 Touchsc
文件 107 2014-10-07 06:51 Touchsc
文件 107 2014-10-07 06:51 Touchsc
目录 0 2014-10-07 06:51 Touchsc
文件 18080 2014-10-07 06:51 Touchsc
文件 95 2014-10-07 06:51 Touchsc
文件 3496 2014-10-07 06:51 Touchsc
文件 178 2014-10-07 06:51 Touchsc
文件 45956 2014-10-07 06:51 Touchsc
文件 90 2014-10-07 06:51 Touchsc
目录 0 2014-10-07 06:51 Touchsc
文件 4125 2014-10-07 06:51 Touchsc
文件 4280 2014-10-07 06:51 Touchsc
文件 4764 2014-10-07 06:51 Touchsc
文件 4184 2014-10-07 06:51 Touchsc
文件 4112 2014-10-07 06:51 Touchsc
文件 5252 2014-10-07 06:51 Touchsc
文件 9100 2014-10-07 06:51 Touchsc
文件 4112 2014-10-07 06:51 Touchsc
文件 4300 2014-10-07 06:51 Touchsc
文件 27544 2014-10-07 06:51 Touchsc
文件 4852 2014-10-07 06:51 Touchsc
文件 5676 2014-10-07 06:51 Touchsc
文件 4112 2014-10-07 06:51 Touchsc
文件 202 2014-10-07 06:51 Touchsc
文件 674 2015-07-28 11:02 说明.txt
- 上一篇:基于单片机的心型灯设计.rar
- 下一篇:基于单片机的串口多机通信6机
相关资源
- 进程外com组件实现win764位软件调用3
- 解决在WIN10 64或WIN7 WIN8 安装protel99 S
- usbisp ii WIN7/8线驱动-双龙JUNGO-Atmel-
- UnityDownloadAssistant-2017
- unity路径工具Itween插件
- 1019Win7版本转换.rar
- unity真实反射shader mirror_shaders
- Win7右键扩展菜单管理器
- win7_32位系统大内存补丁_最大支持12
- win7蓝牙万能驱动
- Win7 64位 旗舰版 安装CodeWarrior5.1的方法
- win7精简版APM驱动添加
- UnityTerrain2MeshV3
- Unity3-2019所有可破解安装包.txt
- unity 读取手机相册
- Unity游戏人工智能AI开发
- T4M unity 地形插件
- LitJson for unity
- win7 超级终端
- CH340驱动(USB串口驱动)_XP_WIN7-win10全
- Unity3D客户端PureMVC框架视屏讲解
- XR21x141x-XP2KVista7-DriversOnly-Vers1.9.0.0XR
- unity3d斗地主
- Oculus SDK 开发必备 OculusIntegration_1.39
- Unity内置着色器源码 builtin_shaders-5.6
- Unity内置着色器源码 builtin_shaders-201
- Unity4.x从入门到精通课本及源码
- Shader编程教程 完整
- Unity3d视频教程
- 炜煌打印机USB驱动For Win7
评论
共有 条评论