3.設定 MRTK 設定檔3. Configuring the MRTK profiles

在本教學課程中,您將了解如何自訂和設定 MRTK 設定檔。In this tutorial, you will learn how to customize and configure the MRTK profiles.

MRTK 設定檔是巢狀設定檔的樹狀結構,其構成了 MRTK 系統和功能應如何初始化的組態設定資訊。The MRTK profiles is a tree of nested profiles that make up the configuration information for how the MRTK systems and features should be initialized. 最上層設定檔 (組態設定檔) 包含每個主要核心系統的巢狀設定檔。The top-level profile, the Configuration Profile, contains nested profiles for each of the primary core systems. 每個巢狀設定檔都是設計來設定其對應系統的行為。Each nested profile is designed to configure the behavior of their corresponding system.

此特定範例將示範如何藉由變更空間網格觀察器的設定,來隱藏空間感知網格。This particular example will show you how to hide the spatial awareness mesh by changing the settings of the Spatial Mesh Observer. 不過,您也可以遵循這些相同原則,自訂 MRTK 設定檔中的任何設定或值。However, you may follow these same principles to customize any setting or value in the MRTK profiles.

正如您在進行上一個教學課程的期間將專案部署至 HoloLens 2 時所經歷的體驗,空間感知網格是代表環境幾何的網格所形成的集合。As you experienced when you deployed your project to your HoloLens 2 during the previous tutorial, the Spatial Awareness mesh is a collection of meshes representing the geometry of the environment. 一開始,這樣的視覺效果很有用,但我們一般會將此功能關閉,以免遇到開啟此功能時所會遭遇的視覺干擾和額外的效能減損。It's a helpful visualization to see initially but it's typically turned off to avoid the visual distraction and the additional performance hit of having it on.

目標Objectives

  • 了解如何自訂和設定 MRTK 設定檔Learn how to customize and configure MRTK profiles
  • 隱藏空間感知網格Hide the spatial awareness mesh

變更空間感知顯示選項Changing the Spatial Awareness Display Option

隱藏空間感知網格所需採取的主要步驟如下:The main steps you will take to hide the spatial awareness mesh are:

  1. 複製預設的組態設定檔Clone the default Configuration Profile
  2. 啟用空間感知系統Enable the Spatial Awareness System
  3. 複製預設的空間感知系統設定檔Clone the default Spatial Awareness System Profile
  4. 複製預設的空間感知網格觀察器設定檔Clone the default Spatial Awareness Mesh Observer Profile
  5. 變更空間感知網格的顯示Change the visibility of the spatial awareness mesh

注意

根據預設,您無法編輯 MRTK 設定檔。By default, the MRTK profiles are not editable. 這些是預設的設定檔範本,您必須先加以複製,才能進行編輯。These are default profile templates that you have to clone before they can be edited. 其中有數個巢狀的設定檔層。There are several nested layers of profiles. 因此,在設定一個或多個設定時,通常會複製及編輯數個設定檔。Therefore, it is common to clone and edit several profiles when configuring one or more settings.

1.複製預設的組態設定檔1. Clone the default Configuration Profile

注意

組態設定檔是最上層的設定檔。The Configuration Profile is the top-level profile. 因此,若要編輯任何其他設定檔,您必須先複製組態設定檔。Consequently, to be able to edit any other profiles, you first have to clone the Configuration Profile.

在 [階層] 視窗中,選取 [ MixedRealityToolkit ] 物件,然後在 [偵測器] 視窗中,確認 MixedRealityToolkit 設定設定檔已設定為 DefaultXRSDKConfigurationProfileIn the Hierarchy window, select the MixedRealityToolkit object, then in the Inspector window, verify that the MixedRealityToolkit Configuration Profile is set to the DefaultXRSDKConfigurationProfile:

已選取 DefaultHoloLens2ConfigurationProfile 的 Unity MixedRealityToolkit 元件

在仍選取 MixedRealityToolkit 物件的情況下,在 [偵測器] 視窗中按一下 [複製與自訂] 按鈕來開啟 [複製設定檔] 視窗:With the MixedRealityToolkit object still selected, in the Inspector window, click the Copy & Customize button to open the Clone Profile window:

Unity MixedRealityToolkit 元件的 [複製與自訂] 按鈕

在 [複製設定檔] 視窗中,輸入適當的 設定檔名稱,例如 GettingStarted_XRSDKConfigurationProfile,然後按一下 [ 複製 ] 按鈕,以建立 DefaultXRSDKConfigurationProfile 的可編輯複本:In the Clone Profile window, enter a suitable Profile Name, for example, GettingStarted_XRSDKConfigurationProfile, then click the Clone button to create an editable copy of the DefaultXRSDKConfigurationProfile:

Unity MixedRealityToolkit 複製的 [組態設定檔] 快顯視窗

新建立的組態設定檔現在已指派為您場景的組態設定檔:The newly created Configuration Profile is now assigned as the Configuration Profile for your scene:

已套用新建立自訂 HoloLens2ConfigurationProfile 的 Unity MixedRealityToolkit 元件

在 Unity 功能表中,選取 [檔案] > [儲存],即可儲存場景。In the Unity menu, select File > Save to save your scene.

提示

請記得在整個教學課程中儲存工作。Remember to save your work throughout the tutorials.

2.啟用空間感知系統2. Enable the Spatial Awareness System

在 [階層] 視窗中選取 MixedRealityToolkit 物件,在 [偵測器] 視窗中選取 [空間感知] 索引標籤,然後勾選 [啟用空間感知系統] 核取方塊:In the Hierarchy window, select the MixedRealityToolkit object, then in the Inspector window, select the Spatial Awareness tab, and then check the Enable Spatial Awareness System checkbox:

已啟用 [空間感知系統] 的 Unity MixedRealityToolkit 元件

注意

針對未來的專案,如果您的應用程式不需要回應環境或與其互動,建議您讓空間感知保持關閉狀態,以降低效能成本。For future projects, if your app doesn't need to respond to or interact with the environment, it's recommended to keep the spatial awareness turned off to reduce performance cost.

3.複製預設的空間感知系統設定檔3. Clone the default Spatial Awareness System Profile

在 [空間感知] 索引標籤中,按一下 [複製] 按鈕以開啟 [複製設定檔] 視窗:In the Spatial Awareness tab, click the Clone button to open the Clone Profile window:

已選取 [空間感知] 索引標籤的 Unity MixedRealityToolkit 元件

在 [複製設定檔] 視窗中,輸入適當的 設定檔名稱,例如 GettingStarted_XRSDKSpatialAwarenessSystemProfile,然後按一下 [ 複製 ] 按鈕,以建立 DefaultXRSDKSpatialAwarenessSystemProfile 的可編輯複本:In the Clone Profile window, enter a suitable Profile Name, for example, GettingStarted_XRSDKSpatialAwarenessSystemProfile, then click the Clone button to create an editable copy of the DefaultXRSDKSpatialAwarenessSystemProfile:

Unity MixedRealityToolkit 複製的 [空間感知系統設定檔] 快顯視窗

新建立的空間感知系統設定檔現在會自動指派給您的組態設定檔:The newly created Spatial Awareness System Profile is now automatically assigned to your Configuration Profile:

已套用新建立自訂 MixedRealitySpatialAwarenessSystemProfile 的 Unity MixedRealityToolkit 元件

4.複製預設的空間感知網格觀察器設定檔4. Clone the default Spatial Awareness Mesh Observer Profile

在仍選取 [ 空間感知 ] 索引標籤的情況下,展開 [ XR SDK Windows Mixed Reality 空間網格觀察 者] 區段,然後按一下 [ 複製 ] 按鈕以開啟 [複製設定檔] 視窗:With the Spatial Awareness tab still selected, expand the XR SDK Windows Mixed Reality Spatial Mesh Observer section, then click the Clone button to open the Clone Profile window:

已擴充 Windows Mixed Reality [空間網格觀察者] 區段的 Unity MixedRealityToolkit 元件

在 [複製設定檔] 視窗中,輸入適當的 設定檔名稱,例如 GettingStarted_MixedRealitySpatialAwarenessMeshObserverProfile,然後按一下 [複製] 按鈕,以建立 DefaultMixedRealitySpatialAwarenessMeshObserverProfile 的可編輯複本:In the Clone Profile window, enter a suitable Profile Name, for example, GettingStarted_MixedRealitySpatialAwarenessMeshObserverProfile, then click the Clone button to create an editable copy of the DefaultMixedRealitySpatialAwarenessMeshObserverProfile:

Unity MixedRealityToolkit 複製的 [空間網格觀察者設定檔] 快顯視窗

新建立的空間感知網格觀察器設定檔現在會自動指派給您的空間感知系統設定檔:The newly created Spatial Awareness Mesh Observer Profile is now automatically assigned to your Spatial Awareness System Profile:

已套用新建立自訂 MixedRealitySpatialAwarenessMeshObserverProfile 的 Unity MixedRealityToolkit 元件

5.變更空間感知網格的顯示5. Change the visibility of the spatial awareness mesh

在 [空間網格觀察器設定] 中,將 [顯示選項] 變更為 [遮蔽],以隱藏仍在運作的空間對應網格:In the Spatial Mesh Observer Settings, change the Display Option to Occlusion to make the spatial mapping mesh invisible while still functional:

[空間網格觀察者顯示選項] 設定為 [遮蔽] 的 Unity MixedRealityToolkit 元件

注意

雖然空間對應網格看不到,但仍存在且正常運作。Although the spatial mapping mesh is not visible, it is still present and functional. 例如,空間對應網格後方的任何全像投影 (實體牆後方的全像投影等) 將不會顯示。For example, any holograms behind the spatial mapping mesh, such as a hologram behind a physical wall, will not be visible.

您方才已了解如何修改 MRTK 設定檔中的設定。You just learned how to modify a setting in the MRTK profile. 如您所見,為了自訂 MRTK 設定,您必須先建立預設設定檔的複本。As you can see, to customize the MRTK settings, you first need to create copies of the default profiles. 由於預設設定檔無法編輯,因此當您想要還原為預設設定時,一律可以參考這些設定。Because the default profiles are not editable, you will always have them as references if you want to revert to the default settings. 若要深入了解 MRTK 設定檔及其架構,您可以參閱 MRTK 文件入口網站中的 MRTK 設定檔設定指南To learn more about MRTK profiles and their architecture, you can refer to the MRTK profile configuration guide in the MRTK Documentation Portal.

恭喜!Congratulations

在本教學課程中,您已了解如何複製、自訂和設定 MRTK 設定檔和設定。In this tutorial, you learned how to clone, customize, and configure MRTK profiles and settings.