Search Issue Tracker
By Design
Votes
0
Found in
2017.4.1f1
Issue ID
1024374
Regression
Yes
Event OnTriggerExit2D is not called when disabling GameObject
To reproduce:
1. Download attached project "Example.zip" and open in Unity
2. Open "Test" scene
3. Enter Play mode
4. In Scene view drag "GameObject" onto "GameObject1"
5. Observe Console that it throws a message "active"
6. Disable "GameObject"
Expected results: In Console, it throws a message "dead active"
Actual results: In Console, no message is thrown
Notes:
- This issue reproduces on both Windows and OSX
Reproduced on Unity 2017.4.1f1, 2018.1.0f1 and 2018.2.0b1
Not reproduced on Unity 2017.3.2f1 and 2017.4.0f1
Regression on Unity 2017.4.1f1
Comments (3)
-
sssetz
Apr 21, 2020 20:45
SO this seems great in theory, but I am testing right now and it does not fire via scripts....if I click/unclick in the Inspector it works, but code based enable/disable does not fire for me.
-
Krejtcha
Aug 27, 2018 13:02
Just migrated from 2017.3.0 to 2018.2.5f1 and I can throw my game away. I was relaying on this functionality quite a lot and now it does not work. But according to https://docs.unity3d.com/ScriptReference/Collider2D.OnTriggerExit2D.html it should work "Notes: Trigger events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions." Can somebody explain why it does not work anymore, why the change, why the documentation says it should work?
-
Botaurus
Aug 26, 2018 01:53
dang this messed my systems up. Whats up with this change? why??? can't find any info on it
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
- The search field has an additional icon that has no functionality
- Splash Image logo is shown after being removed when pressing the Preview button
- Crash on GenerateParticleGeometry when creating certain particles
- HD Sample Buffer returns black for Rendering Layer Mask when Custom Pass Volume is not active
- SpriteRenderer has wrong input color when associated material uses SRPBatcher
Resolution Note (2018.3.X):
So there's an option in 2D physics settings which controls whether an Exit callback occurs when disabling a Collider2D component: https://docs.unity3d.com/ScriptReference/Physics2D-callbacksOnDisable.html
This should only happen when the "component" is disabled, not the whole GameObject. Previously this was happening (in error) when the GameObject was deactivated and had the potential to cause a crash and indeed did as was reported and fixed here: https://fogbugz.unity3d.com/default.asp?1006679 so while this is reported as a regression, it's actually limiting the callback to its intended behavior which is only reporting if the component is being disabled.
If you perform the above reproduction but instead disable the Collider2D only then you do get a callback. Unfortunately, we cannot safely perform callbacks on a GameObject that is being deactivated.
It should be clear that 3D physics performs no such callbacks at all. This is only available on 2D and only when the component itself is disabled. Destroying/deactivating GameObject do not perform callbacks.