UI Toolkit はイベントシステムを使って入力を処理し、すべてのアクティブなパネルにイベントを送信します。
UI Toolkit のイベントシステムは、IMGUI と古い Input Manager からイベントを受け取ることができます。ナビゲーションイベントは、古い Input Manager で定義された軸から作成されます。その他のイベントは IMGUI イベントキューから発生します。
特定の場合を除いて、イベントシステムを使うためにシーンにコンポーネントを加える必要はありません。
シーンで複数の Panel Settings アセットが使用されている場合、イベントシステムは、Sort Order に従って、それらのパネルにポインターイベントを送信します。ポインターイベントは、パネルが反応するまで、パネルを通して伝搬します。
フォーカスされた要素にイベントを使用して影響を与える最初のパネルが、イベントシステムのフォーカスのあるパネルになります。そのパネルは、別のイベントによって別のパネルがフォーカスパネルになるまで、キーボードイベントを受け取り続けます。
ノート: イベントの伝播を止めることと、要素にフォーカスを与えることは別のことです。例えば、ボタンをクリックする場合、伝播は停止され、ボタンだけが押されたことに反応するようになりますが、ボタンやクリックされたフォーカス可能な要素にフォーカスを与えるなど、クリックに対する他のデフォルトのアクションを防ぐことはできません。
UI Toolkit の UI Documet と uGUI コンポーネントを同時に使用できます。
シーンに最初の uGUI 要素を加えると、Event System と Standalone Input Module が自動的に加えられます。
イベントシステムはシーンを読み込んでイベントを実行し、Standalone Input Module は入力を解釈してイベントの実行を要求します。Standalone Input Module は、他の入力モジュールと置き換えることができます。他の入力モジュールは、どの入力が消費されるのかを変えますが、すべてのイベントはイベントシステムを経由して実行されます。
UI Toolkit は、パネルのソート順を使用し、uGUI キャンバスや他の有効なレイキャストターゲットのソート順と比較して、ポインターイベントを UI Toolkit 要素に送るべきか、uGUI オブジェクトに送るべきか、シーン内の他のものに送るべきかを決定します。同様に、UI Toolkit はイベントシステムの currentSelectedGameObject
を設定して、UI Toolkit パネルがフォーカスを得たいときに、他の uGUI オブジェクトからフォーカスを外すようにします。他の uGUI オブジェクトからフォーカスを外し、uGUI オブジェクトが選択されると、UI Toolkit パネルは自動的にフォーカスを失います。
イベントシステムを手動で加えるには、GameObject > UI > Event System を選択します。
異なる入力システムで UI Toolkit (と uGUI) を使用する場合、異なる入力モジュールとイベントシステムを選択する必要があります。
以下の表は、各入力システムの用途に必要なコンポーネントと設定について説明しています。
使用法 | 必須コンポーネント | 実際の入力処理 |
---|---|---|
古い Input Manager を使った UI Toolkit 要素 | デフォルトのイベントシステムを使用。シーンコンポーネントは必要ありません。 | Input Manager (旧). |
Input System パッケージを使った UI Toolkit 要素 | Input System UI Input Module と Event System コンポーネント。 | Input System パッケージ (新) |
古い Input Manager を使った UI Toolkit 要素と uGUI コンポーネント | Standalone Input Module と Event System コンポーネント。 | Input Manager (旧) または 両方 |
Input System パッケージを使った UI Toolkit 要素と uGUI コンポーネント | Input System UI Input Module と Event System コンポーネント。 | Input System パッケージ (新) または 両方 |
UI Toolkit は Input System パッケージと一緒に使うことができます。
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.