1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Unity コンポーネント/エディタ/ウィンドウの関数呼び出し順序

Last updated at Posted at 2025-08-06

Editモードでの関数呼び出し順序を調べました。
毎フレーム呼ばれる関数は一部端折っちゃってます。

[ExecuteAlways]を付けてるモノビヘとエディタ

[ExecuteAlways]Editモードでの関数呼び出し順序
    コンパイル時の動き
        MonoBehaviour OnDisable
        Editor OnDisable
        MonoBehaviour OnValidate
        MonoBehaviour OnEnable
        Editor Reset
        Editor Awake
        Editor OnEnable
        Editor CreateInspectorGUI
        Editor OnInspectorGUI
    オブジェクト選択
        Editor Reset
        Editor Awake
        Editor OnEnable
        Editor CreateInspectorGUI
        Editor OnInspectorGUI
        Editor OnInspectorGUI
        Editor OnInspectorGUI
    オブジェクト非選択
        Editor OnDisable
        Editor OnDestroy
    ロック状態でのオブジェクト選択・非選択
        Editor OnInspectorGUI
    コンポーネント追加
        MonoBehaviour Awake
        MonoBehaviour OnEnable
        MonoBehaviour OnValidate
        Editor Reset
        Editor Awake
        Editor OnEnable
        Editor OnInspectorGUI
        Editor OnInspectorGUI
        Editor OnInspectorGUI
        MonoBehaviour Start
        MonoBehaviour Update
        Editor CreateInspectorGUI
        Editor OnInspectorGUI
    コンポーネント削除
        MonoBehaviour OnDisable
        MonoBehaviour OnDestroy
        Editor OnDisable
        Editor OnDestroy

EditorWindow

EditorWindow
    開く
        Window Reset
        Window Awake
        Window OnEnable
        Window CreateGUI
        Window OnFocus 何故か2回
        Window OnGUI マウス操作などウィンドウ上で操作中に頻繁に
        Window Update 毎フレーム
        Window OnInspectorUpdate 0.1秒に1回
    閉じる
        Window OnLostFocus
        Window OnDisable
        Window OnDestroy
    タブが隠れる
        Window OnLostFocus
    タブが再度現れる
        Window OnFocus
        Window Update 毎フレーム
        Window OnInspectorUpdate 0.1秒に1回
    開いたまま別のウィンドウにフォーカス
        Window OnLostFocus
        Window Update 毎フレーム
        Window OnInspectorUpdate 0.1秒に1回
    開いたまま別のウィンドウにフォーカスしていた状態から隠れる
        Window OnFocus
        Window OnLostFocus

イベント関数の実行順序 - Unity マニュアル がパっと見ワケわからないし載ってない部分もあったので。

モノビヘの実行順序を調べるコードをどなたかが書いてたのを参考・拡張したがリンクを失念。すみません。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?