How to Intercept Unity "Save Scene As.." right after saving?

Hello, everyone!

So, I have a problem where my application needs to get the name of a saved scene right after pressing the “Save Scene as…” button. How can this be achieved?

I tried using AssetModificationProcessor with OnWillSaveAssets, but this gives me the exact moment BEFORE finishing saving and I need the exact moment AFTER save is finished.

Answering my own question, I had to create a Singleton and fill the FileSystemWatcher delegates:

[ExecuteInEditMode]
class SceneNameSingleton : MonoBehaviour
{
	private FileSystemWatcher m_SceneFileWatcher;	// This watches to see if we have saved the level

	private static SceneNameSingleton instance;

	static GameObject genericSingletonGO;
	public static string SINGLETON_NAME = "Singleton";

	public static SceneNameSingleton Instance
	{
		get
		{
			if( instance == null )
			{
				if( genericSingletonGO == null )
				{
					genericSingletonGO = GameObject.Find( SINGLETON_NAME );
					if( genericSingletonGO == null )
						genericSingletonGO = new GameObject( SINGLETON_NAME );

					
				}

				if( genericSingletonGO != null && genericSingletonGO.GetComponent<SceneNameSingleton>( ) != null )
				{
					instance = genericSingletonGO.GetComponent<SceneNameSingleton>( );
				}
				else
				{  
					instance = genericSingletonGO.AddComponent<SceneNameSingleton>( );
				}
			}
			return instance;
		}
	}

	void OnSceneFileWatcher_Created( object sender, FileSystemEventArgs e )
	{
        if( e.FullPath.Contains( ".meta" ) ) return;
        if( !e.FullPath.Contains( ".unity" ) ) return;

		Debug.Log( "OnSceneFileWatcher_Changed" );
		string sceneName = System.IO.Path.GetFileNameWithoutExtension( e.FullPath );
		Debug.Log( "File: " + sceneName + " " + e.ChangeType );
	}

	void OnEnable( )
	{
		Debug.Log( "OnEnable" );
		m_SceneFileWatcher = new FileSystemWatcher( Path.GetFullPath( "Assets" ), "*.unity" );
		m_SceneFileWatcher.Filter = "*.*";
		m_SceneFileWatcher.NotifyFilter = NotifyFilters.LastWrite;
		m_SceneFileWatcher.EnableRaisingEvents = true;

		m_SceneFileWatcher.Created += new FileSystemEventHandler( OnSceneFileWatcher_Created );
		m_SceneFileWatcher.Changed+= new FileSystemEventHandler( OnSceneFileWatcher_Created );
	}
}

This way everytime a unity scene is created or modified it’ll be detected and logged.