Search Issue Tracker
By Design
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
- Crash on RaiseException when opening a specific project
- DownloadHandlerScript.CompleteContent is called twice when building for WebGL
- Scene view has Y coordinates of the Screen Position node flipped when some of the URP features are disabled
- Volumetric fog shader variants are missing from build when "Strict Shader Variant Matching" is disabled
- Unnecessary modifications clutter the Scene when using a RectTransform driven by a LayoutGroup in a Prefab
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