reuseCollisionCallbacks
Determines whether the garbage collector should reuse only a single instance of a Collision type for all collision callbacks.
阅读时间1 分钟最后更新于 1 个月前
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.PhysicsModule
public static bool reuseCollisionCallbacks { get; set; }
Remarks
When an MonoBehaviour.OnCollisionEnter(Collision), MonoBehaviour.OnCollisionStay(Collision) or MonoBehaviour.OnCollisionExit(Collision) collision callback occurs, the Collision object passed to it is created for each individual callback. This means the garbage collector has to remove each object, which reduces performance.
When this option is true, only a single instance of the Collision type is created and reused for each individual callback. This reduces waste for the garbage collector to handle and improves performance.