facebook twitter hatena line email

Unity/VR/WebXR

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

WebXRとは

WebGLで動作するVR用アセット

準備

  1. Unityメインメニュー/Window/PackageManager/左上の+/gitURL選択し、以下を追加
https://github.com/De-Panther/unity-webxr-export.git?path=/Packages/webxr
https://github.com/De-Panther/unity-webxr-export.git?path=/Packages/webxr-interactions
  • WebXR Exportのバージョン0.15.0-preview
  • WebXR Interactionsのバージョン0.15.0-preview

がインストールされてることを確認。

サンプルインストール

  1. Unityメインメニュー/Window/PackageManager/
  2. WebXR InteractionsのSamplesボタンからImportしてインストール
  3. Assets/Samples/WebXRInteractions/0.15.0-preview/SampleSceneがあることを確認

WebXRのテンプレート追加

  1. Unityメインメニュー/Window/WebXR/CopyWebGLTempletes
  2. Assets/WebGLTemplatesが追加されることを確認。
  3. Unityメインメニュー/File/BuildSettings/ProjectSettingのWebGLのWebGLTemplateに、WebXR2020などが追加されてることを確認

WebXRExportの設定

  1. Unityメインメニュー/Edit/ProjectSetting/XRPluginManagement/Plug-inProviders
  2. WebXR Exportにチェック
  3. Assets/XR/XRGeneralSettings.assetの設定ファイルが、追加されたことを確認。

WebGL表示時に圧縮JSを展開できない場合

ProjectSettings/WebGL/PublishingSettings/DecompressionFallbackにチェックを付ける

参考:https://kingmo.jp/kumonos/unity-webgl-unable-parse-build/

"The type or namespace name 'WebXR'"エラーが出る時

エラー詳細

error CS0246: The type or namespace name 'WebXR' could not be found (are you missing a using directive or an assembly reference?)

以下ファイルのPackageのWebXRの"autoReferenced"値を、falseから、trueへ更新すれば良い。

Library/PackageCache/com.de-panther.webxr@0.15.0-preview/Runtime/WebXR.asmdef
"autoReferenced": true,

参考:https://github.com/De-Panther/unity-webxr-export/issues/123

キャラクタを画面内に見せる

Assets/Samples/WebXR\ Interactions/0.14.1-preview/Sample\ Scene/Prefabs/WebXRCameraSet.prefab のpositionを(0, 1, -4)へ

参考

https://qiita.com/kkoba84/items/39f6ceaa6508c475ba6a