6.封裝並部署至裝置或模擬器6. Packaging & deploying to device or emulator

概觀Overview

在上一個教學課程中,您已新增一個簡單按鈕,將棋子重設為其原始位置。In the previous tutorial, you added a simple button that resets the chess piece to its original position. 在此最後一節中,您將會準備好要在 HoloLens 2 或模擬器上執行的應用程式。In this final section, you'll get the app ready to run on a HoloLens 2 or an Emulator. 若有 HoloLens 2,您可以從電腦串流或封裝應用程式,以直接在裝置上執行。If you have a HoloLens 2, you can either stream from your computer or package the app to run directly on the device. 如果沒有裝置,您會封裝應用程式以在模擬器上執行。If you don't have a device, you'll be packaging the app to run on the Emulator. 本節結束時,您將會有一個可以播放的已部署混合實境應用程式,這是透過互動和 UI 完成的。By the end of this section, you'll have a deployed mixed reality app that you can play, complete with interactions and UI.

目標Objectives

  • [僅限裝置] 利用全像應用程式遠端處理串流至 HoloLens 2[Device only] Streaming to HoloLens 2 with holographic app remoting
  • 封裝應用程式並將其部署至 HoloLens 2 裝置或模擬器Packaging and deploying the app to a HoloLens 2 device or emulator

[僅限裝置] 串流[Device Only] Streaming

在此情況下,全像遠端處理表示將電腦或獨立 UWP 裝置中的資料串流至 HoloLens 2,而不是切換管道。Holographic Remoting in this case means streaming data from a PC or standalone UWP device to the HoloLens 2, not switching the channel. 其運作方式是遠端主機應用程式會從 HoloLens 接收輸入資料流程、在虛擬沉浸式檢視中呈現內容,以及透過 Wi-fi 將內容框架串流回 HoloLens。The way this works is a remoting host app receives an input data stream from a HoloLens, renders content in a virtual immersive view, and streams content frames back to HoloLens over Wi-Fi. 串流可讓您將遠端沉浸式檢視新增至現有的桌上型電腦軟體,並可存取更多系統資源。Streaming allows you to add remote immersive views into existing desktop PC software and has access to more system resources.

如果您是使用國際象棋應用程式前往此路由,將需要進行一些事項:If you're going this route with the chess app, you'll need a few things:

  1. 從您的 HoloLens 2 上的 Microsoft Store 安裝全像攝影遠端播放程式並執行應用程式。Install the Holographic Remoting Player from the Microsoft Store on your HoloLens 2 and run the app. 請記下應用程式中顯示的 IP 位址。Note your IP address displayed in the app.

  2. 回到 Unreal 編輯器,移至 [編輯] > [專案設定],然後勾選 [全像攝影遠端處理] 區段中的 [啟用遠端處理]。Back in the Unreal editor, go to Edit > Project Settings and check Enable Remoting in the Holographic Remoting section.

  3. 重新啟動編輯器,然後輸入您裝置的 IP 位址 (如全像遠端處理播放程式中所顯示),接著按一下 [連線]。Restart the editor, then enter your device's IP address (as displayed in the Holographic Remoting Player app), then click Connect.

連線之後,請按一下 [播放] 按鈕右邊的下拉箭號,然後選取 [VR 預覽]。Once you’re connected, click the drop-down arrow to the right of the Play button and select VR Preview. 這會在 [VR 預覽] 視窗中執行應用程式,進而串流至 HoloLens 頭戴式裝置。This will run the app in the VR Preview window, which is streamed to the HoloLens headset.

透過裝置入口網站封裝和部署應用程式Packaging and deploying the app via device portal

注意

如果這是您第一次為適用於 HoloLens 的 Unreal 應用程式進行封裝,則需從 Epic Launcher 下載支援的檔案。If this is your first time packaging an Unreal app for HoloLens, you'll need to download supporting files from the Epic Launcher.

  • 移至 [編輯器喜好設定] > [一般] > [原始程式碼] > [原始程式碼編輯器],並確認已選取 [Visual Studio 2019]。Go to Editor Preferences > General > Source Code > Source Code Editor and check that Visual Studio 2019 is selected.
  • 移至 Epic Games Launcher 中的 [程式庫] 索引標籤、選取 [啟動] 旁邊的下拉箭號,然後按一下 [選項]。Go to the Library tab in the Epic Games Launcher, select the dropdown arrow next to Launch >and click Options.
  • 在 [目標平台] 中,選取 HoloLens 2,然後按一下 [套用]。Under Target Platforms, select HoloLens 2 and click Apply. 變更專案設定中的目標平台Change target platform in project settings
  1. 移至 [編輯] > [專案設定]。Go to Edit > Project Settings.
    • 在 [專案] > [描述] > [關於] > [專案名稱] 底下,新增專案名稱。Add a project name under Project > Description > About > Project Name.
    • 在 [專案] > [描述] > [發行者] > [公司辨別名稱] 底下,新增 CN=YourCompanyNameAdd CN=YourCompanyName under Project > Description > Publisher > Company Distinguished Name.

重要

當您嘗試在步驟 3 中產生新的憑證時,將其中一個欄位留空會導致錯誤。Leaving either of these fields blank will result in an error when you try and generate a new certificate in step 3.

重要

發行者的名稱必須採用 LADPv3 辨別名稱格式The publisher's name must be in LADPv3 Distinguished Names Format. 若發行者名稱的格式不正確,在封裝時將會導致「找不到簽署金鑰。A malformed publisher's name leads to the "Signing key not found. 無法以數位方式簽署應用程式。」The app could not be digitally signed." 錯誤。error upon packaging.

專案設定 - 描述

  1. 在 [平台] > [HoloLens] 底下,啟用 [針對 HoloLens 模擬進行建置] 和/或 [針對 HoloLens 裝置進行建置]。Enable Build for HoloLens Emulation and/or Build for HoloLens Device under Platforms > HoloLens.

  2. 按一下 [封裝] 區段 (在 [簽署憑證] 旁邊) 中的 [產生新項目]。Click Generate new in the Packaging section (next to Signing Certificate).

重要

如果您使用的是已產生的憑證,則憑證的發行者名稱必須與應用程式的發行者名稱相同。If you're using an already generated certificate, then the certificate's publisher name must be the same as the application's publisher name. 否則將會導致「找不到簽署金鑰。Otherwise it leads to the "Signing key not found. 無法以數位方式簽署應用程式。」The app could not be digitally signed." 錯誤內容。error.

專案設定 - 平台 - HoloLens

  1. 當系統提示您建立私密金鑰密碼時,請按一下 [無] 以供測試之用。Click None for testing purposes when you're prompted to create a Private Key Password.

產生新的憑證

  1. 移至 [檔案] > [封裝專案],然後選取 [HoloLens]。Go to File > Package Project and select HoloLens.

    • 建立新資料夾來儲存您的封裝,然後按一下 [選取資料夾]。Create a new folder to save your package in and click Select Folder.
  2. 一旦封裝了應用程式後,請開啟 Windows 裝置入口網站移至 [檢視] > [應用程式],然後尋找 [部署應用程式] 區段。Open the Windows Device Portal once the app is packaged, go to Views > Apps and find the Deploy apps section.

  3. 按一下 [瀏覽 ...]、移至您的 ChessApp.appxbundle 檔案,然後按一下 [開啟]。Click Browse..., go to your ChessApp.appxbundle file and click Open.

    • 如果這是您第一次在裝置上安裝應用程式,請勾選 [允許我選取架構套件] 旁的方塊。Check the box next to Allow me to select framework packages if this is the first time you're installing the app on your device.
    • 在下一個對話方塊中,包含適當的 VCLibsappx 檔案 (若為裝置則為 arm64,若為模擬器則為 x64)。In the next dialogue, include the appropriate VCLibs and appx files (arm64 for device, x64 for emulator). 您可以在儲存套件的資料夾內 HoloLens 底下找到這些檔案。You can find these under HoloLens inside the folder where you saved your package.
  4. 按一下 [安裝]Click Install

    • 您現在可以移至 [所有應用程式],然後點選新安裝的應用程式來執行,也可以直接從 Windows 裝置入口網站啟動應用程式。You can now go to All Apps and tap the newly installed app to run it, or you can start the app directly from the Windows Device Portal.

恭喜!Congratulations! 您的 HoloLens 混合實境應用程式已完成,且已可開始使用。Your HoloLens mixed reality application is finished and ready to go. 不過,這不是盡頭。However, this isn't the end of the road. MRTK 有許多獨立功能,您可以將其新增至專案,包括空間對應、注視和語音輸入,甚至是 QR 代碼。MRTK has lots of standalone features that you can add to your projects, including spatial mapping, gaze and voice input, and even QR codes. 如需這些功能的詳細資訊,請參閱 Unreal 開發概觀More information on these features can be found in the Unreal development overview.

下一個開發檢查點Next Development Checkpoint

依循我們配置的 Unreal 開發檢查點旅程,此時您會探索 MRTK核心建置組塊。If you're following the Unreal development checkpoint journey we've laid out, you're in the midst of exploring the MRTK core building blocks. 接下來,您可以繼續進行下一個建置組塊:From here, you can proceed to the next building block:

或者,直接跳到混合實境平台功能和 API 的主題:Or jump to Mixed Reality platform capabilities and APIs:

您可以隨時回到 Unreal 開發檢查點You can always go back to the Unreal development checkpoints at any time.