private void OnTriggerEnter2D(Collider2D collision) { MonoBehaviour[] list = collision.gameObject.GetComponents <MonoBehaviour>(); collision.gameObject.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour mb in list) { if (mb is PlayerController) { if (sH == null) { sH = mb.GetComponent <PlayerStationHandler>(); } sH.SethighlighStation(this); interactible = true; } } }
private void OnTriggerExit2D(Collider2D collision) { if (!interactible) { return; } MonoBehaviour[] list = collision.gameObject.GetComponents <MonoBehaviour>(); collision.gameObject.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour mb in list) { if (mb is PlayerController) { if (sH == null) { sH = mb.GetComponent <PlayerStationHandler>(); } sH.ResetHighlightStation(); interactible = false; } } }