LoginSignup
2
1

More than 3 years have passed since last update.

OculusQuestでUniVRMを使うと「UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors」エラーが出る問題の対策

Last updated at Posted at 2019-06-10

環境:Unity2019.1.5f1 / UniVRM-0.53.0_6b07

tl;dr

"\Assets\VRM\UniVRM\Editor\Format\vrmAssetPostprocessor.cs" を以下のように修正しろ。

#if !VRM_STOP_ASSETPOSTPROCESSOR
 ↓
#if UNITY_EDITOR

現象

ビルドがシェーダーだとかなんだとかのあたりまで進んだ後、以下エラーが出て止まる。
アセットからUniVRMを取り除くとエラーは発生しなくなる。

Build completed with a result of 'Failed'
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00234] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:190 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:96 
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

ちなみにBuildAndRunは出来ないが、PC実行はできるし、Buildで正常動作するapkを作るのには成功する。

原因

UniVRMがアップデートされて、OculusQuestにBuildAndRunするときビルド定数「VRM_STOP_ASSETPOSTPROCESSOR」定義を必須になった?
このビルド定数の設定自体は昔から存在していた。(https://vrm.dev/univrm/univrm_install/)
2019年6月初旬時点ではビルド定数の定義を行っていなくてもBuildAndRunできていたが、2019年6月6日には動かなくなった。
File→BuildSetting→PlayerSettings→OtherSettings→Scripting Define Symbolsに、VRM_STOP_ASSETPOSTPROCESSORを追加……で問題ないはずだが、なんか知らんがプロジェクトを色々さわってると、何かの拍子に上記設定を定義していてもビルドに失敗することがある。
そもそもこれはアセットをインポートするときにスクリプトを実行する関係のものみたいなので、ビルド&ランに影響するはずはない気がするが実際にはこれが悪いようだ。

ワケガワカラナイヨ…。

対策

VRM_STOP_ASSETPOSTPROCESSORによって生成が制限されるクラスを定義している以下のファイルを修正する。
(削除するとドラッグ&ドロップでVRMを取り込めなくなるので都合が悪い)

"\Assets\VRM\UniVRM\Editor\Format\vrmAssetPostprocessor.cs"

#if !VRM_STOP_ASSETPOSTPROCESSOR
 ↓
#if UNITY_EDITOR
2
1
0

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
2
1