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
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
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