private void OnTriggerEnter(Collider other) { if (_pushableLayer == (_pushableLayer | (1 << other.gameObject.layer))) { var triggerZone = other.GetComponent <TriggerZone>(); var listener = other.GetComponentInParent <InteractionListener>(); if (triggerZone != null && listener != null) { if (triggerZone.depth == InteractionDepth.proximity) { _hoverZoneListener = listener; if (listener != _actionZoneListener) { _hoverZoneListener.HoverOn(GetInteractionData()); } } if (triggerZone.depth == InteractionDepth.action) { var buttonDown = -listener.transform.up; var pushAngle = Vector3.Angle(buttonDown, _moveDirection); var validPushAngle = pushAngle <= MinPushAngle; if (listener == _hoverZoneListener && validPushAngle) { _actionZoneListener = listener; _actionZoneListener.ClickDown(GetInteractionData()); } } } } }
private void ClearInteractions() { if (_hoverZoneListener != null) { _hoverZoneListener.HoverOff(GetInteractionData()); _hoverZoneListener = null; } else if (_actionZoneListener != null) { _actionZoneListener.HoverOff(GetInteractionData()); _actionZoneListener = null; } }
private void OnTriggerExit(Collider other) { if (_pushableLayer == (_pushableLayer | (1 << other.gameObject.layer))) { var triggerZone = other.GetComponent <TriggerZone>(); var listener = other.GetComponentInParent <InteractionListener>(); if (triggerZone != null && listener != null) { if (triggerZone.depth == InteractionDepth.action) { if (_actionZoneListener == listener) { _actionZoneListener = null; listener.ClickUp(GetInteractionData()); if (_hoverZoneListener == null || listener != _hoverZoneListener) { listener.HoverOff(GetInteractionData()); } } } if (triggerZone.depth == InteractionDepth.proximity) { if (_hoverZoneListener == listener) { _hoverZoneListener = null; } if (_actionZoneListener != listener || _actionZoneListener == null) { listener.HoverOff(GetInteractionData()); } } } } }