十一、pico+Unity交互开发教程——手指触控交互(Poke Interaction)

一、XR Poke Interactor

  1. 交互包括发起交互的对象(Interactor)和可被交互的对象(Interactable)。XR Interaction Toolkit提供了XR Poke Interactor脚本用于实现Poke功能。
  2. LeftHand ControllerRightHand Controller``物体下创建名为Poke Interactor的空物体,并添加XR Poke Interactor脚本。
  3. 设置XR Poke Interactor中的Attach Transform,在手部模型下创建代表交互点的子物体(如Poke Point),并将其拖至XR Poke Interactor脚本中的Attach Transform处。
  4. 若手部有其他Interactor,可将Poke Interactor添加到LeftHand ControllerRightHand Controller上的XR Interaction Group中,确保一个Interactor起作用时其他Interactor暂时失效。

二、与UI进行触控交互

  1. 添加Tracked Device Graphic RaycasterXR UI Input Module让UI可被交互,在Canvas上添加Tracked Device Graphic Raycaster脚本;

  2. 在EventSystem上添加XR UI Input Module脚本。

三、与物体进行交互

  1. XR Simple Interactable

    • 用红色方块代表可交互物体,添加XR Simple Interactable脚本。
    • XR Simple InteractableInteractable Events中添加事件,如在Select Entered时让方块材质变成黄色,在Hover Exited时让方块材质变回红色。这个在前面学过
    • 由于XR Simple Interactable默认会被其他Interactor触发,为避免手靠近方块时按下手柄Grip键触发Select Entered事件,可将XR Poke Interactor的Interaction Layer Mask和方块挂载的XR Simple Interactable的Interaction Layer Mask进行设置。经测试,在XRI 2.3.2版本下,可将XR Simple Interactable的Interaction Layer Mask单独设置一个层级(如"Poke"),XR Poke InteractorInteraction Layer Mask设置为Everything,使Poke Interactor单独与方块进行交互。 这个也学过;
  2. XR Poke Filter

    • 运行程序时若无法触发Poke,是因为XR Poke Interactor默认勾选了Require Poke Filter,此时能发生Poke交互的物体必须拥有XR Poke Filter组件。
    • 在方块上添加XR Poke Filter组件,可调整Poke Configuration参数,如将Poke Direction设为Negative Y,即手指从上往下触碰方块时可触发Poke

通过以上步骤,我们成功实现了Unity VR中的手指触控交互功能,为VR体验增添了更多自然和直观的交互方式。

相关推荐
切韵9 天前
Unity编辑器扩展:UI绑定复制工具
ui·unity·编辑器
mit6.8249 天前
[muduo] TcpConnection | 回调交互
c++·交互
Allen Bright9 天前
【JS-4.4-键盘常用事件】深入理解DOM键盘事件:提升用户交互体验的关键
javascript·计算机外设·交互
望获linux10 天前
【实时Linux实战系列】实时I/O操作与中断处理
linux·服务器·microsoft·操作系统·交互·rtos·嵌入式软件
10 天前
Lua复习之何为闭包
开发语言·unity·游戏引擎·lua·交互
MarsBighead10 天前
LLM-201: OpenHands与LLM交互链路分析
python·ai·llm·交互·agent
深空数字孪生10 天前
2025年小程序地图打车的5大技术革新:实时路况预测与智能调度升级
大数据·人工智能·unity·性能优化·小程序·游戏引擎
RPGMZ10 天前
RPGMZ 游戏引擎如何与lua进行互相调用 初探
开发语言·javascript·游戏引擎·lua·rpgmz
程序猿多布10 天前
Unity Addressable使用之检测更新流程
unity·addressable
PM大明同学10 天前
Axure PR 9 搜索 百度引擎 设计&交互
交互·axure