How could I intercept a save scene action being run in Unity?

There is some code I would like to run in editor whenever a scene is saved. Is it possible for me to detect somehow when a scene is saved?

  • \$\begingroup\$ Something like answers.unity.com/questions/175931/…? \$\endgroup\$
    – Zibelas
    Jun 15, 2021 at 5:06
  • \$\begingroup\$ @Zibelas, thanks it is helpful. I never even heard about the AssetModificationProcessor. \$\endgroup\$
    – qqqqqqq
    Jun 15, 2021 at 10:19

1 Answer 1


Unity already has a built-in event for doing exactly what you want: EditorSceneManager.sceneSaving


EditorSceneManager.sceneSaving += OnSavingScene;

private void OnSavingScene(UnityEngine.SceneManagement.Scene scene, string path) {
    //do some stuff here
  • \$\begingroup\$ Don't forget to mark scene objects you modify as dirty with EditorUtility.SetDirty(myObjectOrComponent) otherwise those changes will not be reflected in your scene change. \$\endgroup\$
    – Menyus
    Apr 2, 2023 at 9:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .