Esempio n. 1
0
    //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();
        }
    }
Esempio n. 2
0
    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();
        }
    }