LoginSignup
7
7

More than 5 years have passed since last update.

【Unity】エディタが終了する直前に処理を行う

Posted at

Unityのエディタが閉じる直前に何らかの処理を行いたい場合の処理の書き方。
ただし、このスクリプトがシーン中のゲームオブジェクトにアタッチされてないと動かない。

アタッチせずに解決できるソリューションお持ちの方教えて下さい。

Using UnityEngine;
using System.Collections;

[ExecuteInEditMode]
public class APlugin : MonoBehaviour {

    private bool started = false;

    void OnDestroy(){

        if (started) {
            if (!Application.isPlaying) {
                // エディタ終了時の処理
            } else {
                // 普通のプレイ終了時の処理
            }
        }
    }

    void Update(){
        started = Application.isPlaying;
    }
}

OnEditorQuit とかあっても良さそうなのに。

7
7
2

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