4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Oculus Utilities for UnityとOculus Avatar SDKの導入方法

Last updated at Posted at 2018-09-17

はじめに

何番煎じかわかりませんが、ググった時に情報が古い物が多かったので備忘録的に残しておきます。
2018年9月17日時点の情報です。
一部2020年11月15日に確認した情報を含みます。

確認環境

Windows10
Unity2018.2.7f1
Oculus Utilities for Unity 1.28.0
Oculus Avatar SDK 1.29.0
Oculus Rift(CV1) ※使用デバイスを書いていなかったので追記。2021年1月18日

Unityをインストール

まず「Oculus Utilities for Unity」を使用するために、以下のページでサポートされているUnityバージョンを確認します。
https://developer.oculus.com/documentation/unity/latest/concepts/unity-req/

現時点での最新が2018.2.7f1だったので、このバージョンのUnityを以下のページからダウンロードします。
https://unity3d.com/jp/get-unity/download/archive

※2020年11月15日追記
2020年11月15日現在では最新が2019.3でした。

Oculus Utilitiesをインストール

Unityをインストール後に起動し、以下のページからOculusUtilitiesをダウンロードします。
https://developer.oculus.com/downloads/package/oculus-utilities-for-unity-5/

ZIPを解凍すると中に「OculusUtilities.unitypackage」が入っているので、これをUnityのプロジェクトビューにドラッグアンドドロップしてインポート。

Oculus Avatar SDKをインストール

次にOculus Avatar SDKを以下のページからダウンロードし、同様にインポートします。
https://developer.oculus.com/downloads/package/oculus-avatar-sdk/
この段階だとエラーが29件くらいでます。

上記ページに以下のように書かれているのでOculus Integrationをインストールします。

Note: If using Unity, consider using the Unity Integration. This enables the core Oculus APIs, the Platform and Avatar APIs, all of which are necessary to use the Avatar Social Starter sample scene.

翻訳↓

注: Unityを使用している場合は、Unity Integrationの使用を検討してください。これにより、Core Oculus API、PlatformおよびAvatar APIが使用可能になります。これらのAPIは、すべてAvatar Social Starterサンプルシーンを使用するために必要です。

Oculus Integrationをインストール

Oculus Avatar SDKをUnityで使用するために、以下のページからOculus Integrationをインポートします。
https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022

自分の環境だけかもしれませんが、GoogleChromeでアセットストアの「Unityで開く」ボタンを押すとUnityエディターのアセットストアのタブが真っ白なまま読み込まれませんでした。
これについては話がそれるので分けました。

UnityAssetStoreのウェブページ上にある「Unityで開く」ボタンを押すとUnityエディターのアセットストアのタブが真っ白になる不具合の対処法

Oculus Integrationをインポートすると
「This project contains scripts and/or assemblies that use obsolete apis」
というダイアログが表示されますので、「IMade a Backup. Go Ahead!」を選択します。

さらに
「Oculus Utilities has detected that a newer OVRPlugin isavailable.
 Using the newest version is recommended.
 Do you want to enable it?

 Current version:(Unknown)
 Available version:1.29.1」
というダイアログが表示されるので、「Yes」を選択します。
「OVRPlugin has been updated to 1.29.0」
というダイアログが表示されるので「Restart」を選択します。

※2020年11月15日追記
現在ではversion1.52.1にアップデートされます。

これでようやく先ほどまで出ていたエラーが消えます。
消えていない場合はコンソールタブの「Clear」を押してみましょう。
それでも消えていない場合はバージョン違いとか、環境の違いによるものだと思われます。

※2020年11月15日追記
さらに
「New spatialize plugin found. Do you want to upgrade?
 If you choose 'Upgrade', the old plugin will be renamed to AudioPluginOculusSpatializer.old」
というダイアログが表示されるようになっていたので、「Upgrade」を選択します。
「Spatialize plugins has been upgraded.
 Please restart the Unity Editor to complete the upgrade process.」
と表示されるので「Restart」を選択します。

サンプルシーン起動までの手順など

以下のパスにあるサンプルシーンなどを起動すると、
Assets\Oculus\VR\Scenes\Cubes.unity

以下のようなエラーが表示されます。

Multiple plugins with the same name 'ovrplugin' (found at 'Assets/Oculus/VR/Plugins/1.29.0/Win64/OVRPlugin.dll' and 'Assets/Oculus/VR/Plugins/1.28.0/Win64/OVRPlugin.dll'). That means one or more plugins are set to be compatible with Editor. Only one plugin at the time can be used by Editor.

調べてみると、Oculusの公式ページに以下のように書かれてました。
https://developer.oculus.com/documentation/unity/latest/concepts/release-1.14/

Unity 5.6 and later: If you have updated your OVRPlugin version from Utilities, you may see a spurious error message when the Editor first launches saying “Multiple plugins with the same name 'ovrplugin'”. Please disregard.

翻訳↓

Unity 5.6以降:ユーティリティからOVRPluginのバージョンを更新した場合、エディタが最初に「同じ名前の複数のプラグインovrplugin」を起動すると、偽のエラーメッセージが表示されることがあります。無視してください。

との事なので、無視してよいようです。
が、これが毎回出てうざいので消します。

エラー文言の通り、同じ名前のプラグインが入っているのが問題なので、以下のパスの古いほうのプラグインを削除します。
Assets\Oculus\VR\Plugins\1.28.0

これで実行時にもエラーが表示されなくなりました。

と、思ったんですが、一度Unity以外のアプリケーションをアクティブにして、もう一度Unityをアクティブな状態にすると、先ほど消したはずの「Assets\Oculus\VR\Plugins\1.28.0」が自動的に復活します。

これは単純に消すだけではダメなようです。
Assets\Oculus\VR\Plugins\1.28.0\Win64
上記パスにある古いバージョンの方のOVRPlugin.dllファイルをUnityエディター上で選択し、インスペクター上の「Select platforms for plugin」のチェックボックスをすべて外して、「Apply」を押します。
今度こそこれで実行時にもエラーが表示されなくなりました。

以上でサンプルシーンが正常に実行できるはずです。

※2020年11月15日追記
現在はサンプルシーン起動時にエラーが出なくなっていました。
Oculus riftなどのVRHMDを接続していない状態でサンプルシーンを起動すると、
「Unable to start Oculus XR Plugin.」
というエラーが表示されるため、実行時にはVR HMDをPCに接続した状態で行う必要があります。

4
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?