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?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityUnity already has a built-in event for doing exactly what you want: EditorSceneManager.sceneSaving
Usage:
EditorSceneManager.sceneSaving += OnSavingScene;
private void OnSavingScene(UnityEngine.SceneManagement.Scene scene, string path) {
//do some stuff here
}
EditorUtility.SetDirty(myObjectOrComponent)
otherwise those changes will not be reflected in your scene change.
\$\endgroup\$
AssetModificationProcessor
. \$\endgroup\$