Steps to reproduce:
- Open the attached project
- Open Assets/Scenes/SecondScene.unity and note it contains MenuPanel_ReproStripped - a World Space UIDocument (PanelSettings Render Mode = World Space) carrying the engine-serialized picking BoxCollider (m_WorldSpaceCollider)
- Open Assets/Scenes/SampleScene.unity in single mode so SecondScene closes
- Observe the Console
- Then add both scenes to the Scene List (File > Build Profiles) and build the Player from the Editor
- Observe the build result
Actual results: Closing the Scene logs "Cannot destroy Component while GameObject is being activated or deactivated." from UnityEngine.UIElements.UIDocument:RemoveWorldSpaceCollider, called by UIDocument:OnDisable. During a Player build the same error is logged from the build's scene processing, and the Editor-initiated build fails with "Error building Player: Cannot destroy Component while GameObject is being activated or deactivated." (the same build through the BuildPipeline.BuildPlayer API completes as Succeeded but reports the errors).
Expected results: Closing a Scene containing a World Space UIDocument produces no errors - the World Space picking collider is cleaned up without DestroyImmediate running inside the GameObject deactivation - and Player builds from the Editor succeed.
Reproducible with versions: 6000.3.22f1, 6000.5.10f1, 6000.6.0b10, 6000.7.0a5
Can’t test with versions: 6000.0.82f1 (No World Space UI)
Tested on (OS): Windows 11