Reproduction steps:
1. Open the attached project “ExceptionAtRemove”
2. Open the “Assets/Scenes/SampleScene” Scene
3. Enter the Play mode
4. Inspect the Console window
Expected result: The Console window does not throw any messages
Actual result: The Console throws a “NullReferenceException” exception
Reproducible with: 2021.3.25f1, 2022.2.20f1, 2023.1.0b4, 2023.1.0b17, 2023.2.0a15
Not reproducible with: 2023.1.0a1, 2023.1.0b3
Couldn’t test with: 2020.3.48f1 - Errors in user script: “Assets/TestScript.cs(8,40): error CS0246: The type or namespace name 'UIDocument' could not be found (are you missing a using directive or an assembly reference?)”
Reproducible on: macOS 13.3 (Intel)