Unity MR 開發教學

Author: Kelvin Huang

混合實境 (Mixed Reality) 是將虛擬影像與真實世界融合的技術,使用者可以在混合實境同時看到周圍空間與虛擬物件,獲得更直覺與豐富的互動體驗,本教學介紹使用 Unity 遊戲引擎開發 Meta Quest 3 的混合實境應用程式。

首先完成 Meta Quest 基本設定並申請成為 Oculus 開發人員 [教學]

 

建立 Unity 專案,匯入 Meta SDK 資源以提供 Quest2 / Quest3 通透與手部辨識的支援。

開啟 Build Settings 設定,選擇 Android 平台,然後按下 Switch Platform 切換平台。

按下 Player Settings 開啟玩家設定。

 

設定 Scripting Backend = IL2CPP

Api Compatibility Level = .NET Standard 2.1

Minimum API Level = Android 10.0 (API level 29)

XR Plugin Management > Install XR Plugin Management 安裝插件。

勾選 Android 分頁下方的 Oculus 選項安裝 XR 插件。

勾選 Standalone 的 Oculus 插件,即可在連線時進行實機測試。

左側切換到 Oculus 按下 Fix All 修正所有問題。

按下 Apply All 套用全部建議項目。

確認專案設定工具下的所有檢查清單已經完成。

開啟 [ Oculus > Interaction > Samples > Scenes > Examples ] 資料夾,此處收錄部份的展示場景。

開啟 HandGrabExamples 場景,目前有鑰匙、火把、馬克杯等物件,可使用控制器或手勢操作抓握物件。

 

 

開啟 MR 混合實境通透功能

選取 OVRCameraRig 後,透過 Inspector 設定 Passthrough Support = Supported

接著在 Insight Passthrough 下方,勾選 Enable Passthrough 開啟通透功能。

 

按下 Add Component > OVR Passthrough Layer (Script) 腳本元件,並 設定 Placement = Underlay

將房間環境的模型 RoomEnvironment 關閉,複製 DeskSurface 桌面。

檢查 Project Settings 的 Oculus 專案設定工具,若出現錯誤,請按 Fix All 修正全部錯誤。

開啟 Build Settings 視窗,按下 Add Open Scenes 加入場景,再按下 Build 按鈕建置 APK 檔案。

 

製作虛擬鍵盤 [教學]

 

Copyright © 2024 CG Digital Corp. All rights reserved.