Search Issue Tracker
By Design
Votes
2
Found in
5.4.0b9
Issue ID
778391
Regression
Yes
DontDestroyOnLoad throws InvalidOperationException when called from the Editor
How to reproduce:
1. Open attached project
2. Open scene test.unity
- Note that an error appears in the console:
InvalidOperationException: The following game object is invoking the DontDestroyOnLoad method: BaseLoader. Notice that DontDestroyOnLoad can only be used in play mode and, as such, cannot be part of an editor script.
testScript.OnEnable () (at Assets/testScript.cs:11)
- Reproduced in Version 5.4.0b11 (323b0238353b), Version 5.4.0b7 (83df6fa5e23f), Version 5.3.4f1 (fdbb5133b820)
- Not reproducible in Version 5.4.0b6 (2c3d6b93e789), Version 5.2.4f1 (98095704e6fe)
- By Design: DontDestroyOnLoad was never intended to work in edit mode. Only in play mode and standalone players.
- This is why it now throws an exception if it is used in edit mode
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 GUIManager::DoGUIEvent when focusing on the Game view window on a specific project
- Asset creation in the Project Browser is not always undone/inconsistent when the undo shortcut is pressed right after creating an asset
- JobTempAlloc memory leak warning is thrown when the Player is shut down
- Graphics State Collection warm-up does not work when using with Addressables Shaders
- "Baked Shadow Radius" field is visible but inactive when when the Shadow Type is set to "Hard Shadows" under the Light Component
Add comment