XR ゲームやアプリケーションにおける入力処理の主な選択肢は、以下の通りです。
上記の複数の方法を同時に使用する場合もあります。例えば、XR Interaction Toolkit を使用してユーザーが環境内のオブジェクトを拾えるようにし、Input System を使用して一時停止機能をコントローラーの特定のボタンに紐付け、XR.Node API でハードウェアの状態を読み取ってコントローラーゲームオブジェクトを動かせるようにする、などです。
ノート: OpenXR プラグインは、様々な XR デバイスやコントローラーをサポートし、XR 入力とトラッキングデータへの追加的なアクセス方法を独自に提供します。XR Interaction Toolkit、Input System、あるいは XR.InputDevice と XR.Node API は、引き続き使用できます。(OpenXR プラグインを使用する場合、旧 Input Manager はサポートされません。) 詳細は Input in Unity OpenXR を参照してください。
XR Interaction Toolkit は、Input System と基本の UnityEngine.XR API を基盤として構築され、XR 入力をサポートします。このツールキットは、XR 入力を処理したり、ユーザーと環境とシーン UI の相互作用 (インタラクション) を定義するための、ほぼそのまま使用できるコンポーネントのセットを提供します。このツールキットのインタラクションシステムを使用しない場合でも、入力コンポーネントを土台として使用すれば、設定の手間を省くことができます。このツールキットは、入力処理の基本的なアプローチとして以下の 2 つを提供します。
Input System の Action (アクション) に関する詳細は、Action を参照してください。
ヒント: XR Interaction Toolkit の Starter Assets には、アクションベースの入力に伴う反復的な設定作業のほとんどを省略できる、プリセットと入力アクションが提供されています。
XR Interaction Toolkit は、以下の基本的インタラクションを定義します。
XR Interaction Toolkit は、これらのインタラクションを追加的なコンポーネントと共に使用して、ユーザーが環境と相互作用できるようにします。例えば、オブジェクトに GrabInteractable コンポーネントを追加すると、ユーザーは Select をトリガーしてオブジェクトを掴むことができます。デフォルトでは Select は XR コントローラーのグリップボタンに紐付けられていますが、紐付けは自由に変更できます。また、ツールキットで定義されるアクションや紐付けの他に、独自のアクションや紐付けを使用することもできます。
XR コントローラーのボタンやジョイスティックなどの制御へのアクセスは、他のゲームコントローラーへのアクセスと同様に行えます。トラッキングデータにアクセスするには、コード内で XR.InputTracking API を使用します。また、Input System の TrackedPoseDriver コンポーネントを使用して、トラッキングされるデバイス (HMD やコントローラーなど) でゲームオブジェクトを制御することも可能です。Input System を使用していない場合は、Legacy Input Helpers パッケージから TrackedPoseDriver コンポーネントを入手することもできます。
ノート: OpenXR プラグインを使用する場合は、Input System を使用する必要があります。Input Manager はサポートされていません。
XR Hands パッケージは、ハンドトラッキングをサポートする XR デバイスからの、ハンドトラッキングデータへのアクセスを提供します。このデータにアクセスするには、OpenXR バージョン 1.7 などの、ハンドトラッキングのサポート入りで更新された XR プロバイダープラグインを使用する必要があります。
XR Hands パッケージは、以下を提供します。
XR Input API は、XR 入力への直接のアクセスを提供します。この API を使用して、接続されている XR デバイスを見つけ、そのトラッキングデータと入力ハードウェアの状態を読み取ることができます。
XR Input API に関する詳細は、Unity の XR 入力 を参照してください。
デバイスメーカーなどのサードパーティが独自の入力 API やインタラクション API を提供することも多くあり、Unity 提供の API の代わりに (あるいはそれに加えて) 使用することができます。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.