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

相关推荐
孟无岐10 小时前
【Laya】Laya 类使用说明
typescript·游戏引擎·游戏程序·laya
在路上看风景12 小时前
1.2 Unity资源分类
unity·游戏引擎
one named slash12 小时前
BMFont在Unity中生成艺术字
unity·游戏引擎
郝学胜-神的一滴14 小时前
图形学中的纹理映射问题:摩尔纹与毛刺的深度解析
c++·程序人生·unity·游戏引擎·图形渲染·unreal engine
在路上看风景15 小时前
10. CPU-GPU协作渲染
unity
程序员agions15 小时前
Unity 游戏开发邪修秘籍:从入门到被策划追杀的艺术
unity·cocoa·lucene
JIes__15 小时前
Unity(一)——场景切换、退出游戏、鼠标隐藏锁定...
unity·游戏引擎
q_302381955616 小时前
香橙派AI Pro 20T部署DeepSeek:打造本地离线语音助手,实现语音交互自由!
人工智能·交互
mingren_131416 小时前
c++和qml交互
c++·qt·交互
人机与认知实验室16 小时前
2026年,“交互”会出现新的定义
交互