Search Issue Tracker
Duplicate
Votes
19
Found in
2017.2.0a2
Issue ID
923745
Regression
No
EditorSceneManager.sceneClosing callback not called when loading a single scene
I register a callback for the EditorSceneManager.sceneClosing event but it doesn't get called when I open another scene in the editor.
Steps to reproduce:
1. Open the attached project: SceneClosingNotCalled.zip
2. Open alternatively SceneOne and SceneTwo.
3. Observe the Console.
Expected: SomeBehaviourEditor.OnSceneClosing() gets called and a message about it gets printed in the console.
Actual result: No message is printed in the console about closing the scene and the function SomeBehaviourEditor.OnSceneClosing() is not called.
Note: If the two scenes are loaded additively and then one of them gets Unloaded or Removed then the closing callback gets executed as I would expect.
Tested in Unity 2017.2.0a2
-
Adrian-Miasik
Feb 21, 2020 19:38
Dropping in to say I'm also having this problem in 2018.4.0f1
-
essoperagma
Feb 19, 2019 08:08
Same on 2018.3.2.
I am currently using this workaround:UnityEditor.SceneManagement.EditorSceneManager.sceneOpening += OnSceneOpening;
private void OnSceneOpening(string path, OpenSceneMode mode)
{
if (EditorSceneManager.sceneCount < 2 && mode == OpenSceneMode.Single)
{
// A scene is being opened in single mode. Which means another one is being closed.
}
}This only covers the case where sceneClosing event doesn't work. Therefore, you should still register to sceneClosing event for scenes that are being closed/unloaded in additive mode.
-
Fuzzinator
Oct 18, 2018 05:08
The problem still exists in 2018.2.12f
-
dogzerx2
Feb 16, 2018 23:56
I've got this problem too.
I guess I'll let it be, assuming it will be fixed. An AssetStore product throws an error on scene change and only way to avoid it is if this callback method works.
-
angrypenguin
Jan 27, 2018 06:56
Same problem here, 2017.2.0f3. Also, same behaviour when a scene is opened with EditorSceneManager.OpenScene(buildScene.path, UnityEditor.SceneManagement.OpenSceneMode.Single).
-
Dekonator
Jan 25, 2018 15:36
Having this problem too in 2017.3.0f3
-
jerg33
Oct 23, 2017 18:00
Having the same problem but with version 7.1.1f1
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Shader warnings are thrown after building High Definition 3D template
- "EndLayoutGroup: BeginLayoutGroup must be called first" error is thrown when changing Shader Precision Model from the Build Profiles window
- White artifacts/outlines are visible in the Garden Scene when viewing at meshes from a distance
- Shader warnings "Sprite-Unlit-Default" are thrown after building 2D Platrformer Microgame Template
- [Android] HLSL shader becomes corrupted when running on an Android device
This is a duplicate of issue #1003257