LoginSignup
0

More than 3 years have passed since last update.

[Unity] ビルド時のXRSettingsの変更を反映してビルドする

Last updated at Posted at 2019-10-07

Unityのバージョン: Unity2018.2.21
エディタ拡張を用いて、各プラットフォーム向けにビルドする際、XRSettings.LoadDeviceByName()を使用してビルドしても反映されないので調べた。
String[]の順番を変えれば、優先順位の変更もできる。

// Oculus Integration → OpenVR(Unityビルトイン)の優先順位に設定
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone,new String[] { "Oculus", "OpenVR"});

なお、上記で実行すると、PlayerSettingsが恒久的に切り替わるので注意。
ビルド前の設定を維持したい場合は、上記スクリプトの実行前にXRSettings.supportedDevicesを取得して保持しておくとよい。

参考
How to change Virtual Reality SDKs list in Unity Build settings (via script)
SetVREnabledOnTargetGroup / not always working / Cardboard issue - Unity Forum

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
0