既存の UXML ドキュメントを UXML ドキュメント内で テンプレートインスタンス としてインスタンス化することができます。
プロジェクト内の既存の UXML ドキュメントをテンプレートとして使用するには、以下を行います。
.uxml
) を見つけます。テンプレートインスタンス は TemplateContainer
タイプの通常の要素のように Hierarchy に表示されます。.uxml
ファイル名は、右側にグレイアウトの状態で表示されます。テンプレートインスタンス を展開すると、インスタンスの内部階層を見ることができます。この内部階層は、要素を使う で説明したように、読み取り専用で、参照用です。
UXML ドキュメント内に、テンプレートインスタンス としてサブドキュメントを作ることができ、それを再利用できます。
これはまた、サブドキュメントを既存のドキュメントの テンプレートインスタンス としてインスタンス化します。
テンプレートインスタンス として使用される元の UXML ドキュメントを編集するには、テンプレートインスタンス を右クリックし、以下のオプションのいずれかを選択します。
UI Builder で開く。現在の UXML ドキュメントをアンロードし、テンプレートインスタンス をロードします。
分離してインスタンスを開く: テンプレートインスタンス をロードしている間、現在の UXML ドキュメントをバックグラウンドでロードしたままにします。Hierarchy と Canvas には テンプレートインスタンス のコンテンツのみが表示され、StyleSheets ペインには背景の親 UXML ドキュメントのスタイルシートが読み取り専用で表示されます。これは、スタイルシートがまだ テンプレートインスタンス に適用されているためです。
コンテキストでインスタンスを開く: 現在の UXML ドキュメントをロードしたまま、そのすべての要素を読み取り専用にし、Hierarchy と Canvas にグレーアウトした状態で表示します。親 UXML ドキュメントのコンテキスト内で テンプレートインスタンス のコンテンツを編集できます。このオプションを使用すると、ホストドキュメントのコンテキストを失うことなく、テンプレートインスタンス のコンテンツを更新することができます。
プロジェクトに表示: Project ウィンドウに テンプレートインスタンス ファイルの場所を表示します。
2 番目と 3 番目のオプションでは、Viewport の上にパンくずメニューが表示されます。これを使用して、親 UXML ドキュメントに戻ることができます。
単一の テンプレートインスタンス を展開するには、テンプレートインスタンス を右クリックし、Unpack Instance を選択します。これで、テンプレートインスタンス が通常の UXML ドキュメントに変わります。
すべての テンプレートインスタンス を展開するには、テンプレートインスタンス を右クリックし、Unpack Instance Completely を選択します。これで、すべての テンプレートインスタンス が通常の UXML ドキュメントに変わります。
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.