Search Issue Tracker
Fixed in 2021.2.X
Fixed in 2020.3.X, 2021.1.X
Duplicate in 2021.1.X
Votes
0
Found in
2017.4
2019.3.9f1
2020.2
Issue ID
1239147
Regression
No
OnEnable/OnDisable is called the second time when setting GameObject's instance flags to HideAndDontSave
How to reproduce:
1. Open the attached project's Scene labeled "MyScene"
2. In the Hierarchy, select the "GameObject"
3. In the Inspector, Right-Click the "Hide And Dont Save Object" Component
4. From the context menu, select the "CreateInstanceWithHideFlags" option
5. Observe the Console Window
Expected result: OnEnable/OnDisable functions are called once
Actual result: OnEnable/OnDisable functions are called multiple times
Note: The extra deactivation and activation comes from UnityScene::HandleChangingPhysicsScenes
Reproducible with: 2017.4.40f1, 2018.4.22f1, 2019.3.11f1, 2020.1.0b6, 2020.2.0a8
-
_watcher_
May 05, 2020 08:15
OnEnable/OnDisable triggering multiple times has been an issue in the Editor for many years. I had to stop using these completely and implement my own solution, unfortunately. Still would be awesome if they worked properly.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- TreeView Child display toggle styling becomes reversed when clicking and dragging it
- Null is returned when using FocusOutEvent.relatedTarget
- Unity_BaseInstanceID is always zero when rendering multiple meshes and instancing with the same buffer
- UI Document button's text does not resize relatively when size in percentage (%) is used
- Event.current.mousePosition has an offset of 1px along the y-axis in WebGL build when the mouse button is released
Resolution Note (fix version 2021.2):
Setting certain hide flags internally removes the object from the scene into a separate hidden scene. The deactivation/reactivation of objects needs to happen to ensure the object does not reach a point where it belongs to one scene, but is affected by the physics of another scene. The extra round of activations can be worked around by deactivating the gameObject first, setting the hideFlags and Activating the object again.
Fixed in 2021.2.0a5
Resolution Note (fix version 2020.3):
Fixed in Unity 2020.3.2f1