傳統型應用程式中的全像全像遠端Holographic Remoting in desktop app

注意

0.1.3 套件版本已新增 Windows 獨立應用程式遠端支援。Windows Standalone app remoting support was added in the 0.1.3 package release. 從版本0.1.3,此功能不支援 UWP 組建。As of version 0.1.3, this feature doesn’t support UWP builds.

  1. 遵循全像全像遠端設定的步驟Follow the steps in Holographic Remoting setup

  2. 開啟 [ 編輯-> 專案設定],流覽至 XR 外掛程式管理,然後選取 [ Windows Mixed Reality 功能集 ] 方塊。Open Edit -> Project Settings, navigate to XR plug-in Management, and check the Windows Mixed Reality feature set box. 此外,取消核取 [ 啟動時初始化 XR]:Also, uncheck Initialize XR on Startup:

    未核取 [啟動時,在 Unity 編輯器中開啟初始化 XR] 的 [專案設定] 面板螢幕擷取畫面

  3. 展開 [ OpenXR ] 底下的 [功能] 區段,然後選取 [全部顯示]Expand the Features section under OpenXR and select Show All

  4. 核取全像 應用程式遠端處理 的核取方塊:Check the Holographic App Remoting checkbox:

    在 Unity 編輯器中開啟的 [專案設定] 面板的螢幕擷取畫面,其中已啟用應用程式遠端功能

  5. 接下來,撰寫一些程式碼來設定遠端設定,並觸發 XR 初始化。Next, write some code to set the remoting configuration and trigger XR initialization. 使用 Mixed Reality OpenXR 外掛程式 散發的範例應用程式包含 AppRemoting,其中顯示在執行時間連接到特定 IP 位址的範例案例。The sample app distributed with the Mixed Reality OpenXR Plugin contains AppRemoting.cs, which shows an example scenario for connecting to a specific IP address at runtime. 此時將範例應用程式部署到本機電腦,將會顯示具有 [連接] 按鈕的 IP 位址輸入欄位。Deploying the sample app to a local machine at this point will display an IP address input field with a connect button. 輸入 IP 位址,然後按一下 [連線],將會初始化 XR 並嘗試連線到目標裝置:Typing an IP address and clicking Connect will initialize XR and attempt to connect to the target device:

    顯示範例應用程式遠端 UI 範例應用程式的螢幕擷取畫面

  6. 若要撰寫自訂的連接程式碼,請使用已填寫的進行呼叫 Microsoft.MixedReality.OpenXR.Remoting.AppRemoting.Connect RemotingConfigurationTo write custom connection code, call Microsoft.MixedReality.OpenXR.Remoting.AppRemoting.Connect with a filled-in RemotingConfiguration. 範例應用程式會在偵測器中顯示這項功能,並示範如何從文字欄位填入 IP 位址。The sample app exposes this in the inspector and shows how to fill in the IP address from a text field. 呼叫 Connect 會設定並自動初始化 XR,這也是為什麼必須以協同程式的方式來呼叫它:Calling Connect will set the configuration and automatically initialize XR, which is why it must be called as a coroutine:

    StartCoroutine(Remoting.AppRemoting.Connect(remotingConfiguration));
    
  7. 執行時,您可以使用 API 取得目前的線上狀態 AppRemoting.TryGetConnectionState ,並選擇性地使用中斷連接和解除初始化 XR AppRemoting.Disconnect()While running, you can obtain the current connection state with the AppRemoting.TryGetConnectionState API, and optionally disconnect and de-initialize XR using AppRemoting.Disconnect(). 這可用來中斷連線,然後重新連線到相同應用程式會話內的不同裝置。This could be used to disconnect and reconnect to a different device within the same app session. 範例應用程式會提供 tappable cube,以在點擊時中斷遠端會話的連接。The sample app provides a tappable cube which will disconnect the remoting session if tapped.

從先前的 Api 遷移Migration from previous APIs

UnityEngine. XR HolographicRemotingUnityEngine.XR.WSA.HolographicRemoting

Unity檔的範例程式碼:From the sample code on Unity's docs:

XR.Wsa。HolographicRemotingXR.WSA.HolographicRemoting OpenXR. AppRemotingOpenXR.Remoting.AppRemoting
HolographicRemoting.Connect(String) AppRemoting.Connect(RemotingConfiguration)
HolographicRemoting.ConnectionState AppRemoting.TryGetConnectionState(out ConnectionState, out DisconnectReason)
StartCoroutine(LoadDevice("WindowsMR")) [N/A:呼叫時自動發生 AppRemoting.Connect[N/A: Automatically happens when calling AppRemoting.Connect]

UnityEngine. XR. WindowsMR. WindowsMRRemotingUnityEngine.XR.WindowsMR.WindowsMRRemoting

XR.WindowsMR.WindowsMRRemotingXR.WindowsMR.WindowsMRRemoting OpenXR. AppRemotingOpenXR.Remoting.AppRemoting
WindowsMRRemoting.Connect() AppRemoting.Connect(RemotingConfiguration)
WindowsMRRemoting.Disconnect() AppRemoting.Disconnect()
WindowsMRRemoting.TryGetConnectionState(out ConnectionState)WindowsMRRemoting.TryGetConnectionFailureReason(out ConnectionFailureReason)WindowsMRRemoting.TryGetConnectionState(out ConnectionState) and WindowsMRRemoting.TryGetConnectionFailureReason(out ConnectionFailureReason) AppRemoting.TryGetConnectionState(out ConnectionState, out DisconnectReason)
WindowsMRRemoting.isAudioEnabled, WindowsMRRemoting.maxBitRateKbps, WindowsMRRemoting.remoteMachineNameWindowsMRRemoting.isAudioEnabled, WindowsMRRemoting.maxBitRateKbps, WindowsMRRemoting.remoteMachineName AppRemoting.Connect經由結構傳遞至 RemotingConfigurationPassed into AppRemoting.Connect via the RemotingConfiguration struct
WindowsMRRemoting.isConnected AppRemoting.TryGetConnectionState(out ConnectionState state, out _) && state == ConnectionState.Connected