github英文:https://github.com/TouchScript/TouchScript/wiki/The-Journey-of-a-Touch-Point


The Journey of a Touch Point

This section describes how a touch pointer originated at user's finger gets to a gesture.

这个环节来解释,一个来自用户手指的touch pointer是如何到gesture动作的。

(理解这个环节非常重要!!!!!!!!!!!)

First, a touch pointer comes to an Input Source. It doesn't matter what touch-enabled device is used, it might be mouse or a fake pointer generating script. All input sources have CoordinatesRemapperproperty which may contain an instance of ICoordinatesRemapper. In this case all touch pointers go through it before getting to TouchManager.

首先,一个touch pointer来自一个输入源。无所谓是什么样的可触摸设备,可能是一个mouse pointer或者是一个fake pointer。所有的输入源都是有坐标重映射的属性,该属性包含ICoordinatesRemapper的实例。在这种情况下,所有的touch pointers都重映射然后到TouchManager。

Remappers are used when an input device isn't aligned to the screen correctly.
It might be necessary to rotate or scale data to match the screen.

为什么要重映射呢?因为输入设备的坐标系要和unity屏幕坐标对齐。

Since many pointer events can theoretically arrive between frames, TouchManager keeps them in buffers till the next Update. During the next Update all messages are processed and the following events are dispatched in the following order:

由于许多pointer events都在两帧之间来到,TouchManager把它们保存在缓冲区内知道下一帧。在下一帧,所有的消息都会被处理,接下来的事件就会按照如下顺序分发:

Before dispatching PointersPressed TouchManager goes through all instances of TouchLayer in the scene to determine if one of them wants to take pressed pointers (note: there might be several pointers pressed during a frame).

The most used layer type is StandardLayer. It checks if a ray originated from camera's position hits any collider or UI element in the scene. If it does, the system checks if there are any instances of HitTest attached to target object. They can intercept successful raycasts and modify them. For example Untouchable makes it impossible to touch an object.

Note: before version 9.0 there was a CameraLayer, which is now merged into StandardLayer.

Layer sets current target of a pointer which is accessible via Pointer.GetPressData() method.

在分发PointersPressed事件之前,TouchManager会遍历TouchLayer的所有实例,来决定它们中的任何一个想要接受这个pressed pointers。

最常用的layer类型是StandardLayer。它检查摄像机的射线是否hit到任何一个collider或者UI元素上。如果hit上了,系统会检查是否有HitTest的实例附载在该目标物体上。他们可以拦截射线并且更改射线。比如说Untouchable就是触摸一个物体变得不可能。

Layer设置了当前目标pointer,通过Pointer.GetPressData()设置的。

When Target is determined, touch pointer goes to GestureManager with PointersPressed event. GestureManager checks if any gesture on the target or in its transform hierarchy is interested in this pointer. This process is a bit tricky.

当决定了一个目标对象,touch pointer会通过PointersPressed事件到GestureManager。GestureManager检查目标对象上的任何动作是否对该pointer有兴趣。过程有点复杂。

For example we have an interface shown on the image above with nested boxes. When user touches box E the system looks for all the gestures on boxes from the root object to the Target which are able to receive touch input (in this case boxes EC and A). If there's no active gesture in the graph containing the Target, all gestures get the touch pointer until one of them changes its state to Recognized or Began.

So, let's assume that some gesture on box E got this touch point and started. It now owns this touch pointer and all other gestures in the graph which are not friendly to this gesture and returned true from CanBePreventedByGesture(gesture) will be forced to fail and reset.

例如,上面的图像中显示了一个带有嵌套框的接口。
当用户触摸E这个box,系统从根对象到目标对象查找所有在box上的能够接收到touch input的gesture(在这种情况下盒子E、C和A)。如果没有active的动作在包含目标的graph上,所有动作获取touch pointer,直到它们中的一个更改状态到Recognized或者Began。

假设box E上的一些gesture获得了这个touch point并且开始了。。
它现在拥有这个touch pointer和graph中的所有其他手势,这些手势对这个手势不友好,从canbetedbygesture(手势)返回true,将被迫失败和重置。

Now user touches box C which is a parent container of box E. The system once again grabs all gestures on yellow boxes but checks them against all the gestures on green boxes. In this case a gesture on box E is active and prevents all gestures starting from C and up from beginning.

To make gestures in hierarchy work together we need to add one to another's Friendly gestures property in inspector or via AddFriendlyGesture(gesture) method. If gestures are friendly they can share owned touch pointers.

When PointersUpdatedPointersReleased or PointersCancelled events occur, the process is much simpler since only gestures which own touch pointers from an event will be notified.

So, that's how a touch pointer goes all the way from an input device to gestures.

现在用户触摸box C,它是box E的父容器。系统再次抓取黄色盒子上的所有gesture,并将它们与绿色盒子上的所有gesture进行对比。
在本例中,box E上的一个gesture是active的,它阻止所有从C开始和从开始的gesture。

为了使gesture在层次结构中协同工作,我们需要在检查器中或通过AddFriendlyGesture(gesture)方法将一个手势添加到另一个的Friendly gesture属性中。
如果手势友好,它们可以共享自己的touch pointers。

当pointersupdate、pointersrelease或pointerscancated事件发生时,过程要简单得多,因为只有拥有来自事件的touch pointer的gesture才会得到通知。

这就是触摸指针从输入设备到手势的全部过程。

TouchScript中文---The Journey of a Touch Point相关推荐

  1. TouchScript中文---Pointer Input

    本博主要是看到github上有TouchScript的基本的文档,想要翻译成中文,加深一下理解,同时写一下自己的想法. 原文博客:https://github.com/TouchScript/Touc ...

  2. TouchScript中文---Gestures

    github英文:https://github.com/TouchScript/TouchScript/wiki/Gestures Gestures In TouchScript all gestur ...

  3. Unity 触摸插件 TouchScript遇到的坑

    说在前面,我现在的项目使用TouchScript 是因为突然改需求要用触摸屏.原本TouchScript的功能根本不能满足项目用. 网上找到大部分教学都没有说怎么用Script写其他功能,所以只能一步 ...

  4. shields 徽标_创意讲故事徽标的剖析

    shields 徽标 重点 (Top highlight) 设计 (DESIGN) A few years ago I had the pleasure of getting together wit ...

  5. php @touch,touch - [ php中文手册 ] - 在线原生手册 - php中文网

    用户评论: [#1] csouth at xistins dot com [2014-12-14 08:41:04] An earlier comment referenced a code snip ...

  6. 【poj 2488】A Knight's Journey 中文题意题解代码(C++)

    题目链接: http://poj.org/problem?id=2488 中文题意: 给出一个p行q列的国际棋盘,马可以从任意一个格子开始走,问马能否不重复的走完所有的棋盘.如果可以,输出按字典序排列 ...

  7. CVPR2019论文题目中文列表

    英文题目 中文题目   Finding Task-Relevant Features for Few-Shot Learning by Category Traversal 少镜头学习中用类别遍历法寻 ...

  8. linux中文麻酱字_【树】Linux笔记 1

    以下内容是参与[生信技能树-全球听第7期]的课程笔记,记录人:小瑛  ,有问题可在公众号后台留言 小白小白,请注意:笔记中出现的所有文件路径,仅作为参考,请勿模仿! 1. 登录服务器 1.1 Mac电 ...

  9. 金融领域首个开源中文BERT预训练模型,熵简科技推出FinBERT 1.0

    出品 | AI科技大本营 头图 | CSDN付费下载于东方IC 为了促进自然语言处理技术在金融科技领域的应用和发展,熵简科技 AI Lab 近期开源了基于 BERT 架构的金融领域预训练语言模型 Fi ...

最新文章

  1. Spring Security 实战干货:OAuth2第三方授权初体验
  2. mysql安全性实验心得_mysql安全小结
  3. SQL语句:SQLwhile(0=0)与while @@fetch_status=0.
  4. windows 2012 如何设置取消禁拼ping
  5. Another approach to enable table edit in SE16
  6. 安装Python3的工具包报Microsoft Visual C++ 14.0 is required的错误
  7. [vue] 使用vue渲染大量数据时应该怎么优化?说下你的思路!
  8. Spark在美团的实践
  9. 基于jsp+mysql+Spring+hibernate+在线学习交流论坛平台
  10. debian9为什么默认是pip2_Debian9 安装后基本配置
  11. Adobe 修复严重的 Photoshop 缺陷
  12. python画曲线图-如何使用python画曲线图
  13. Flash/Flex学习笔记(50):3D线条与填充
  14. JavaMaven【三、常用指令】
  15. day01函数的重载
  16. Java-面向对象编程-三大特性之多态
  17. 有关聊天机器人的近两年的优秀论文和开源程序
  18. html中的圆圈链接,html – 如何在svg圈内添加链接
  19. Obi Rope(Yanlz+Unity+柔性电缆+立钻哥哥+)
  20. .Net工程师面试笔试宝典

热门文章

  1. 《大腕》经典对白 模仿秀(转贴)
  2. 计算机季度函数,excel返回季度的五个公式
  3. 【对流氓软件说ByeBye】—— 恶意软件删除工具
  4. kettle使用 - 关闭Carte服务
  5. epublib java_java中使用Epublib解析EPub文件
  6. AI工程师 需要掌握的技能
  7. 《安富莱嵌入式周报》第285期:电子技术更新换代太快,我要躺平,Linux内核6.1已经并入RUST,一夜161个网站密码遭泄,Matlab精选课件,开源电子书
  8. 【AI技术】物体识别概述1
  9. 便签内容如何从旧手机转到新手机?
  10. linux批量处理图片