Version: 2022.3
  • C#


Suggest a change


Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.


Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.



public LayerMask callbackLayers;


The Layers that this Collider2D will report collision or trigger callbacks for during a contact with another Collider2D.

When a contact occurs between two Collider2D, each Collider2D will get a collision or trigger callback. This options allows you to select which layer(s) will produce a callback.

The ability to limit which layers will result in a callback can reduce the complexity of the script inside the callback so that it can safely assume only specific layers will be reported. There is also a performance benefit in not performing callbacks that are not required.

These are all the physics callbacks which are affected by callback layers:


  • This does not control whether the Collider2D will come into contact or not but simply if the resultant callback will happen.
  • Even if all callback layers are selected, only contacts captured via Collider2D.contactCaptureLayers, will be reported.
  • The other Collider2D involved in any contact callback disabled here will still receive callbacks defined by its own callbackLayers property.
  • Normally both the Collider2D and the Rigidbody2D it is attached to receive a callback therefore this option controls both those component callbacks.
  • When enabling callback layers where callbacks already exist, those contacts will not be reported as new contacts i.e. there will not be an OnCollisionEnter2D or OnTriggerEnter2D callback produced.

Additional resources: LayerMask.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。