Search Issue Tracker
By Design
By Design in 2023.3.X
Votes
0
Found in
2021.3.29f1
2022.3.8f1
2023.1.10f1
2023.2.0b7
2023.3.0a2
Issue ID
UUM-47111
Regression
No
ScriptableObject instances are destroyed when calling EditorSceneManager.NewScene
How to reproduce:
1. Open the attached “new-scene-behavior.zip“ project
2. Run Script (Bugreport > Run Example Code)
Expected result: The ScriptableObject instance isn’t destroyed
Actual result: The ScriptableObject instance is destroyed and “MissingReferenceException: The object of type 'Editor.MyTestScriptableObject' has been destroyed but you are still trying to access it.“ error in the Console
Reproducible with: 2021.3.29f1, 2022.3.8f1, 2023.1.10f1, 2023.2.0b7, 2023.3.0a2
Reproducible on: macOS 13.4.1 Ventura (Intel)
Not reproducible on: No other environment tested
Note: User reported that saving the ScriptableObject and reloading it after the call to NewScene() works, but is not the expected behavior
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
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
Resolution Note:
Current behavior is the expected behavior.
When any type of object is instantiated it is considered part of a scene unless it is made into an asset.
Which means when the scene is destroyed so is all instantiated objects.
So either make the object into an assets, or set DontSave hideflag which will also keep the object alive as mentioned in the documentation https://docs.unity3d.com/ScriptReference/HideFlags.DontSave.html
Resolution Note (2023.3.X):
Current behavior is the expected behavior.
When any type of object is instantiated it is considered part of a scene unless it is made into an asset.
Which means when the scene is destroyed so is all instantiated objects.
So either make the object into an assets, or set DontSave hideflag which will also keep the object alive as mentioned in the documentation https://docs.unity3d.com/ScriptReference/HideFlags.DontSave.html