コガネブログ

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

【Unity】プレハブモードを開始した、終了した、保存した時に呼び出されるイベント

概要

using UnityEditor;
using UnityEditor.Experimental.SceneManagement;
using UnityEngine;

[InitializeOnLoad]
public static class Example
{
    static Example()
    {
        PrefabStage.prefabSaved        += OnPrefabSaved;
        PrefabStage.prefabSaving       += OnPrefabSaving;
        PrefabStage.prefabStageClosing += OnPrefabStageClosing;
        PrefabStage.prefabStageOpened  += OnPrefabStageOpened;
    }

    private static void OnPrefabSaved( GameObject gameObject )
    {
        Debug.Log( "OnPrefabSaved" );
    }

    private static void OnPrefabSaving( GameObject gameObject )
    {
        Debug.Log( "OnPrefabSaving" );
    }

    private static void OnPrefabStageClosing( PrefabStage prefabStage )
    {
        Debug.Log( "OnPrefabStageClosing" );
    }

    private static void OnPrefabStageOpened( PrefabStage prefabStage )
    {
        Debug.Log( "OnPrefabStageOpened" );
    }
}