XR ゲームやアプリケーションにおける入力処理の主な選択肢は、以下の通りです。
上記の複数の方法を同時に使用する場合もあります。例えば、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.
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:
See Actions for more information about Input System Actions.
ヒント: XR Interaction Toolkit の Starter Assets には、アクションベースの入力に伴う反復的な設定作業のほとんどを省略できる、プリセットと入力アクションが提供されています。
XR Interaction Toolkit は、以下の基本的インタラクションを定義します。
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.
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 はサポートされていません。
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 入力 を参照してください。
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,