//call interact gui private void OnTriggerEnter(Collider other) { IInteractable temp = other.GetComponent <IInteractable>(); IOnEnterInteractable autoInteract = other.GetComponent <IOnEnterInteractable>(); if (temp != null) { OnEnterInteractable?.Invoke(); focus = temp; } if (autoInteract != null) { autoInteract.Enter(); } }
private void OnTriggerExit(Collider other) { IInteractable temp = other.GetComponent <IInteractable>(); IOnEnterInteractable autoInteract = other.GetComponent <IOnEnterInteractable>(); if (temp == focus) { if (temp != null) { temp.LeaveInteract(); } OnExitInteractable?.Invoke(); focus = null; } if (autoInteract != null) { autoInteract.Leave(); } }