コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Destroy may not be called from edit mode! Use DestroyImmediate instead.

Destroy may not be called from edit mode! Use DestroyImmediate instead.
Also think twice if you really want to destroy something in edit mode. 
Since this will destroy objects permanently.

エディタ拡張の処理でGameObject.Destroyを呼び出すと上記のエラーが発生します
エディタ拡張でゲームオブジェクトを削除したいときは
GameObject.DestroyImmediateを使用する必要があります