private void OnTriggerExit2D(Collider2D collision) { WallMagnet magnet = collision.GetComponent <WallMagnet>(); if (magnet != null && magnets.Contains(magnet)) { magnets.Remove(magnet); } }
private void OnTriggerEnter2D(Collider2D collision) { WallMagnet magnet = collision.GetComponent <WallMagnet>(); if (magnet != null) { magnets.Add(magnet); } }