2
0

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 1 year has passed since last update.

[Unity] ビルド時にシーンが参照されたときのコールバック

2
Last updated at Posted at 2019-12-09

Unityバージョン

2019.2.14f

問題提起

IProcessScene というインターフェースがかつていたらしい1
が、リファレンスをあさる限り、2018.1以降"Method group is Obsolete"2、つまり古いと書かれている。

では、代わりは一体何か。

探求

`IProcessScene`が`IProcessSceneWithReport`になっていました。
とりあえず`IProcessScene`でぐぐると、ドンピシャなのではというQ&Aを発見。 > Remote Settingsを利用する際、Asset Storeからパッケージをインポートすると、次のようなコンパイルエラーが発生します。 > > ``` > Assets/Editor/RemoteSettings/RemoteSettingsLinker.cs(23,18): error CS0535: `UnityEngine.Analytics.RemoteSettingsLinker' does not implement interface member `UnityEditor.Build.IPreprocessBuild.OnPreprocessBuild(UnityEditor.BuildTarget, string)' > > Assets/Editor/RemoteSettings/RemoteSettingsLinker.cs(23,18): error CS0535: `UnityEngine.Analytics.RemoteSettingsLinker' does not implement interface member `UnityEditor.Build.IPreprocessBuild.OnPreprocessBuild(UnityEditor.BuildTarget, string)' > ``` > [^3]

読み進めると、IProcessSceneIProcessSceneWithReportに置き換わっている様子なので、スクリプトリファレンスを見てみる。

https://docs.unity3d.com/ja/2019.2/ScriptReference/Build.IProcessSceneWithReport.OnProcessScene.html

ビンゴ。恐らく、引数にBuild.Reporting.BuildReportが加わってあたらしくなったためだろう。

結論

インターフェースIProcessSceneWithReportを継承し、OnProcessSceneを実装すべし。

  1. 【Unity】エディタ拡張で使用できるコールバックを40個まとめて紹介 - コガネブログ

  2. Build.IProcessScene - Unity スクリプトリファレンス - 2018.1のドキュメント。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?