Steps to reproduce:
- Create a new Universal 2D project via Unity Hub
- Edit > Project Settings > Editor > "Enter Play Mode Settings": enable Enter Play Mode Options and disable Domain Reload
- In the Project Browser right click and Create > 2D > Sprites > Triangle and Select the texture
- In the Inspector click "Open Sprite Editor" (or Window > 2D > Sprite Editor)
- Draw a Cube Sprite container in the Sprite Editor
- Do NOT click Apply in the Sprite Editor. Press Play to enter Play Mode
- In the "Unapplied import settings" dialog that appears, click Apply
- Observe the Console
Actual results: An exception is thrown:
Exception: AssetDatabase.ForceReserializeAssets cannot be used when in play mode
UnityEditor.AssetDatabase.ForceReserializeAssets (...)
UnityEditor.U2D.Sprites.SpriteEditorWindow.DoApply () (at .../com.unity.2d.sprite@6bfd14f568c2/Editor/SpriteEditor/SpriteEditorWindow.cs:1170)
UnityEditor.U2D.Sprites.SpriteEditorWindow.HandleApplyRevertDialog (...) (at SpriteEditorWindow.cs:865)
UnityEditor.U2D.Sprites.SpriteEditorWindow.RebuildCache () (at SpriteEditorWindow.cs:937)
UnityEditor.U2D.Sprites.SpriteEditorWindow.OnPlayModeStateChanged (...) (at SpriteEditorWindow.cs:838)
Expected results: Unapplied Sprite Editor changes are applied or reverted cleanly before the Play Mode transition, with no exception.
Reproducible with versions: 6000.0.0f1, 6000.0.79f1, 6000.3.20f1, 6000.5.4f1, 6000.6.0b3, 6000.7.0a2
Tested on (OS): Windows 11