Version: 2022.1
言語: 日本語
XR Origin
XR API リファレンス

XR 入力の選択肢

XR ゲームやアプリケーションにおける入力処理の主な選択肢は、以下の通りです。

  • XR Interaction Toolkit
  • OpenXR インタラクションプロファイル
  • Input System や Input Manager を介した “従来的な” 入力
  • XR.InputDevice と XR.Node API
  • サードパーティ製の入力ライブラリ

上記の複数の方法を同時に使用する場合もあります。例えば、XR Interaction Toolkit を使用してユーザーが環境内のオブジェクトを拾えるようにし、Input System を使用して一時停止機能をコントローラーの特定のボタンに紐付け、XR.Node API でハードウェアの状態を読み取ってコントローラーゲームオブジェクトを動かせるようにする、などです。

Note: The OpenXR plug-in, which supports many different XR devices and controllers, provides its own, additional way to access XR input and tracking data. You can still use the XR Interaction Toolkit, the Input System, or the XR.InputDevice and XR.Node APIs. (The legacy Input Manager is not supported when you use the OpenXR plugin.) See Input in Unity OpenXR for more information.

XR Interaction Toolkit

The XR Interaction Toolkit abstracts input into a set of user input actions, such as “hover,” select,“ and ”activate." These actions correspond to conventional XR input

The XR Interaction Toolkit builds on the Input System and the base UnityEngine.XR API to support XR input. It provides a near ready-to-use set of components for handling XR input and defining interactions between the user and the environment and the scene UI. Even if you choose not to use the toolkit’s interaction system, you can use the input components as a starting point to save setup effort. The toolkit provides two basic approaches to handling input:

  • Action-based (アクションベースの) 入力は、最も自在度が高く、複数のコントローラーや入力スキームをより簡単にサポートできます。XR Interaction Toolkit は、一般的な XR 入力のニーズに対応するアクションを定義します。これらのアクションを使用するには、コントローラーのゲームオブジェクトに XR Controller (Action-Based) コンポーネントを追加します。このコンポーネントは、(デバイスベースのオプションを選択した場合を除いて) XR シーンに追加できる、XR Origin の設定の一部になっています。
  • Device-based input is simpler to set up than action-based input, but is not as flexible. To use device-based input with the XR Interaction Toolkit, add the XR Controller (Device-Based) component to your controller GameObjects. This component is already part of the XR Origin configuration when you add it to the scene with the GameObject > XR > Device-based > XR Origin menu command.

See Actions for more information about Input System Actions.

ヒント: XR Interaction Toolkit の Starter Assets には、アクションベースの入力に伴う反復的な設定作業のほとんどを省略できる、プリセットと入力アクションが提供されています。

XR Interaction Toolkit は、以下の基本的インタラクションを定義します。

  • Select: intended for selecting Interactables in the environment
  • Activate: intended for activating Interactables in the environment
  • UI Press: UI 内のボタンなどの制御を押すために使用されます。
  • Rotate anchor: intended for rotating an object held at a distance (with the X-Ray Interactor)
  • Translate anchor: intended for moving an object held at a distance (with the X-Ray Interactor)

The XR Interaction Toolkit uses these interactions with additional components to let the user interact with the environment. For example, if you add a GrabInteractable component to an object, the user can trigger Select to grab it. By default, select is bound to the grip button of an XR controller, but you can change the binding as you see fit. You can also use your own actions and bindings alongside those defined by the toolkit.

Input System と Input Manager

You can access the controls of XR Controllers, such as buttons and joysticks, in the same ways you would access any game controller. To access tracking data, use the XR.InputTracking API in code. You can also use the Input System TrackedPoseDriver component to control a GameObject with a tracked device such as a HMD or controller. The TrackedPoseDriver component is also available from the Legacy Input Helpers package, in case you are not using the Input System.

ノート: OpenXR プラグインを使用する場合は、Input System を使用する必要があります。Input Manager はサポートされていません。

XR Input API

The XR Input APIs provide the lowest level access to XR input. The API lets you find connected XR devices and read their tracking data and state of their input hardware.

XR Input API に関する詳細は、Unity の XR 入力 を参照してください。

サードパーティ製の入力 API

Device makers and other third parties often provide their own input and interaction APIs that you can use instead of or in addition to those provided by Unity. For example,

XR Origin
XR API リファレンス