本日は MRTKv2 の調査枠です。
MRTKv2 の Guides ドキュメントを少しずつ読み進めていきます。
MRTKv2のGuidesドキュメント
以下のドキュメントを読み進めていきます。
microsoft.github.io
以下のページでは有志による本ドキュメントの日本語翻訳が行われています。
投稿時点でこちらで未翻訳、または著者が興味のある部分について記事にしていきます。
hololabinc.github.io
本記事では以下のページを読み進めます。
microsoft.github.io
コンテンツシーンの読み込み
デフォルトでは全てのコンテンツの読み込み操作は非同期であり、加算的です。
マネージャーおよび照明シーンは、コンテンツの読み込み操作の影響を受けません
ロードの進行状況とシーンのアクティブ化の監視については、コンテンツのロードの監視を参照してください。
microsoft.github.io
コンテンツの読み込み
コンテンツシーンを読み込むには LoadContent メソッドを使用します。
IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>(); // Additively load a single content scene // 単一のコンテンツシーンを追加的にロードする await sceneSystem.LoadContent("MyContentScene"); // Additively load a set of content scenes // コンテンツシーンのセットを追加的にロードする await sceneSystem.LoadContent(new string[] { "MyContentScene1", "MyContentScene2", "MyContentScene3" });
シングルシーンの読み込み
単一のシーンのロードに相当するものは、オプションの[mode]引数を使用して実現できます。
LoadSceneMode.Single は、ロードを続行する前に、ロードされた全てのコンテンツシーンをアンロードします。
IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>(); // ContentScene1, ContentScene2 and ContentScene3 will be loaded additively // ContentScene1、ContentScene2、ContentScene3 は追加的にロードされます await sceneSystem.LoadContent("ContentScene1"); await sceneSystem.LoadContent("ContentScene2"); await sceneSystem.LoadContent("ContentScene3"); // ContentScene1, ContentScene2 and ContentScene3 will be unloaded // SingleContentScene will be loaded additively // ContentScene1、ContentScene2、ContentScene3 がアンロードされます // その後、SingleContentScene が追加的にロードされます await sceneSystem.LoadContent("SingleContentScene", LoadSceneMode.Single);
次/前のシーンの読み込み
コンテンツはインデックスの作成順に単独でロードできます。
これは一連のデモンストレーションシーンを1つずつユーザーに案内するショーケースアプリケーションに役立ちます。
以下の次/前のコンテンツのロードでは LoadSceneMode.Single を使用して、前のコンテンツがアンロードされるようにしています。
IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>(); if (nextSceneRequested && sceneSystem.NextContentExists) { await sceneSystem.LoadNextContent(); } if (prevSceneRequested && sceneSystem.PrevContentExists) { await sceneSystem.LoadPrevContent(); }
現在ロードされている最低のビルドインデックスよりも低いビルドインデックスを持つコンテンツシーンが少なくとも1つある場合、PrevContentExists は true を返します。
現在ロードされている最高のビルドインデックスよりも高いビルドインデックスを持つコンテンツシーンが少なくとも1つある場合、NextContentExists は true を返します。
wrap 引数が true の場合、コンテンツは最初/最後のビルドインデックスにループバックします。
これにより、次/前のコンテンツを確認する必要がなくなります。
IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>(); if (nextSceneRequested) { await sceneSystem.LoadNextContent(true); } if (prevSceneRequested) { await sceneSystem.LoadPrevContent(true); }
タグによる読み込み
コンテンツシーンをグループで読み込むことが望ましい場合があります。
例えば、エクスペリエンスのステージは複数のシーンで構成されている場合です。
この場合、全てを同時にロードして機能させる必要があります。
これを容易にするために、シーンにタグを付け、そのタグでロードまたはアンロードすることができます。
IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>(); await sceneSystem.LoadContentByTag("Stage1"); // Wait until stage 1 is complete // ステージ1が完了するまで待ちます await sceneSystem.UnloadContentByTag("Stage1"); await sceneSystem.LoadContentByTag("Stage2");
タグによるロードは、スクリプトを変更せずにエクスペリエンスに要素を組み込み/削除したい場合にも役立ちます。
例えば、次の2つのタグセットを使用してこのスクリプトを実行すると、異なる結果が生成されます。
IMixedRealitySceneSystem sceneSystem = MixedRealityToolkit.Instance.GetService<IMixedRealitySceneSystem>(); await sceneSystem.LoadContentByTag("Terrain"); await sceneSystem.LoadContentByTag("Structures"); await sceneSystem.LoadContentByTag("Vegetation");
タグセット例:1
シーン名 | タグ名 | 読み込み結果 |
---|---|---|
DebugTerrainPhysics | Terrain | 〇 |
StructureTesting | Structures | 〇 |
VegetationTools | Vegetation | 〇 |
Mountain | Terrain | 〇 |
Cabin | Structures | 〇 |
Trees | Vegetation | 〇 |
タグセット例:2
シーン名 | タグ名 | 読み込み結果 |
---|---|---|
DebugTerrainPhysics | DoNotInclude | |
StructureTesting | DoNotInclude | |
VegetationTools | DoNotInclude | |
Mountain | Terrain | 〇 |
Cabin | Structures | 〇 |
Trees | Vegetation | 〇 |