LoginSignup
2
1

More than 3 years have passed since last update.

Unity2017からUnity2018に移行した時に一部のUnityEngineの機能を使っているクラスでコンパイルエラーが出る不具合の対処法

Posted at

背景

Unity2018のLTSも出たということで、Unity 2017で作業していたプロジェクトをUnity 2018に移行しました。
するとエディタのConsole画面にコンパイルエラーが表示され、中身を見てみると以下のようなエラーが出てきました。

Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableStateMachineTrigger.cs(10,50): error CS1070: The type `UnityEngine.StateMachineBehaviour' has been forwarded to an assembly that is not referenced. Enable the built in package 'Animation' in the Package Manager window to fix this error.

(Filename: Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableStateMachineTrigger.cs Line: 10)
Assets/Plugins/UniRx/Scripts/UnityEngineBridge/InspectorDisplayDrawer.cs(88,92): error CS1070: The type `UnityEngine.GUIContent' has been forwarded to an assembly that is not referenced. Enable the built in package 'IMGUI' in the Package Manager window to fix this error.

(Filename: Assets/Plugins/UniRx/Scripts/UnityEngineBridge/InspectorDisplayDrawer.cs Line: 88)
Assets/Plugins/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs(168,39): error CS1070: The type `UnityEngine.WWW' has been forwarded to an assembly that is not referenced. Enable the built in package 'Image Conversion', which is required by package 'Unity Web Request WWW', in the Package Manager window to fix this error.

(Filename: Assets/Plugins/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs Line: 168)
Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ObservableWWW.cs(57,60): error CS1070: The type `UnityEngine.WWWForm' has been forwarded to an assembly that is not referenced. Enable the built in package 'Unity Web Request' in the Package Manager window to fix this error.

(Filename: Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ObservableWWW.cs Line: 57)
Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ObservableWWW.cs(110,35): error CS1070: The type `UnityEngine.AssetBundle' has been forwarded to an assembly that is not referenced. Enable the built in package 'Asset Bundle' in the Package Manager window to fix this error.

(Filename: Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ObservableWWW.cs Line: 110)
Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorInstaller.cs(5,48): error CS1070: The type `UnityEngine.Animator' has been forwarded to an assembly that is not referenced. Enable the built in package 'Animation' in the Package Manager window to fix this error.

(Filename: Assets/Plugins/Zenject/Source/Runtime/AnimatorInterfaces/AnimatorInstaller.cs Line: 5)

Consoleの内容を見る限りPackage Manager関連で不具合が起きていることはわかったので、解決方法を調べてみました。
環境は移行前がUnity2017.4.24f1、移行後はUnity2018.4.0.f1です。

解決方法

Unity Forumで同じようなエラーが発生した記事の投稿があったため、それを実践してみました。

How can I enable the built in package 'IMGUI' in my package manager?

やり方はUnityプロジェクトの中にあるPackageフォルダを削除して、Unityエディタを開き直すとPackageフォルダが再生成され、再生成が終わると無事Consoleからコンパイルエラーが消えます。

原因としてはPackageフォルダ内にあるmanfest.jsonに記述されているmodule関連が上手く移行出来ていなかったため起きていた不具合のようです。
たまたまPlugin関連がエラーの対象になっていましたが、自前のスクリプトでも該当の機能を使っていたら同じようにエラーになっていたと思います。

Packageフォルダの再生成は結構時間がかかったので、manifest.jsonを直接編集した方が早いという記述も先程の記事にもありましたので、そちらも合わせて実践してみても問題ないと思います。

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