How to reproduce:
1. Open the attached “IN-83642“ project
2. Select “Bugreport → Open Window” from the menu bar
3. Observe the order of messages in the Console window (OnEnable → OnBecameVisible)
4. Navigate to “Assets/Editor” in the Project window
5. Right-click the “TestWindow” script and select “Reimport”
6. Observe the Console window
Expected result: OnEnable is called before OnBecameVisible
Actual result: OnBecameVisible is called before OnEnable
Reproducible in: 6000.0.18f1
Not reproducible in: 2021.3.43f1, 2022.3.45f1 (see note about regression)
Reproducible on: Windows 10, Windows 11
Not reproducible on: No other environments tested
Notes:
- in 2021.3.43f1 and 2022.3.45f1, if the project is closed, and then reopened with the window open, OnBecameVisible is called before OnEnable
- There is a regression somewhere between the Unity 2021.3/2022.3 and Unity 6 versions, but test results become inconsistent somewhere around the 2023.2 alpha and beta streams making it difficult to pin down the first affected version