Collider Check to Non Alloc
This commit is contained in:
parent
b93c966218
commit
8a1fdc6f9e
|
@ -7,6 +7,7 @@ namespace Syntriax.Modules.Movement.ColliderTrigger
|
|||
{
|
||||
[SerializeField] private LayerMask colliderMask = 0;
|
||||
private bool _isTrigerred = false;
|
||||
private Collider2D[] results = new Collider2D[8];
|
||||
|
||||
public LayerMask ColliderMask { get => colliderMask; set => colliderMask = value; }
|
||||
|
||||
|
@ -29,7 +30,7 @@ namespace Syntriax.Modules.Movement.ColliderTrigger
|
|||
=> OnTriggered = new UnityEvent<bool>();
|
||||
|
||||
protected void FixedUpdate()
|
||||
=> IsTrigerred = Physics2D.OverlapBox(transform.position, transform.localScale, 0, ColliderMask) != null;
|
||||
=> IsTrigerred = Physics2D.OverlapBoxNonAlloc(transform.position, transform.localScale, 0, results, ColliderMask) > 0;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmosSelected()
|
||||
|
|
Loading…
Reference in New Issue