十一、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体验增添了更多自然和直观的交互方式。

相关推荐
在路上看风景13 小时前
## 2.2 状态同步
unity
霜绛14 小时前
Unity:lua热更新(一)——AB包AssetBundle、Lua语法
笔记·学习·游戏·unity·lua
霜绛14 小时前
Unity:lua热更新(二)——Lua语法(续)
笔记·学习·unity·游戏引擎·lua
yi碗汤园15 小时前
【一文了解】C#反射
开发语言·unity·c#
HahaGiver66616 小时前
Unity Shader Graph 3D 实例 - 基础的模型贴图渲染
3d·unity·游戏程序·贴图·游戏美术
HahaGiver66616 小时前
Unity Shader Graph 3D 实例 - 一个简单的3D打印效果
3d·unity·游戏引擎
AA陈超16 小时前
ASC学习笔记0004:通知相关方能力规格已被修改
c++·笔记·学习·游戏·ue5·游戏引擎·虚幻
愚公搬代码17 小时前
【愚公系列】《MCP协议与AI Agent开发》011-MCP协议标准与规范体系(交互协议与状态码体系)
人工智能·交互
胖胖求游戏20 小时前
Unity热更新——AB包和Lua
unity·游戏引擎·lua
q***064721 小时前
开源模型应用落地-FastAPI-助力模型交互-进阶篇-中间件(四)
开源·交互·fastapi