private void DeactiveLastInteractible() { if (PreviousInteractible == null) { return; } if (PreviousInteractible.GazeSelectable) { StopCoroutine("GazeSelectCountdown"); CurGazeSelectionTime = GazeSelectionTime; ReticleImageSelector.DOFade(1.0f, 0.3f); ReticleImageSelector.fillAmount = 0.0f; SetGazeValue(0.0f); } PreviousInteractible.Out(); PreviousInteractible = null; CurrentInteractible = null; }
private void EyeRaycast() { if (GVRControllerPointer != null && SceneManager.GetActiveScene().name != "AdScene") { //Debug.DrawRay(GVRControllerPointer.position, GVRControllerPointer.forward * GazeDistance, Color.red, 0.1f); } else { //Debug.DrawRay(ReticleCamera.position, ReticleCamera.forward * GazeDistance, Color.red, 0.1f); } Ray ray; ray = new Ray(ReticleCamera.position, ReticleCamera.forward); RaycastHit hit = new RaycastHit(); RaycastHit hideHit = new RaycastHit(); bool showLayersHitOccured = false; bool hideReticeHitOccured = false; showLayersHitOccured = Physics.Raycast(ray, out hit, GazeDistance, ShowLayers); hideReticeHitOccured = Physics.Raycast(ray, out hideHit, GazeDistance, ReticleHideLayers); if (showLayersHitOccured) { Interactible interactible = hit.collider.gameObject.GetComponent <Interactible>(); _reticalCenterImage.DOFade(1.0f, 0.3f); _reticleHidden = false; if (interactible == null) { _reticalOuterImage.DOFade(0.0f, 0.3f); if (CurrentInteractible != null && CurrentInteractible != PreviousInteractible) { //Debug.Log("No interactible, but have a current one"); CurrentInteractible.Out(); CurrentInteractible = null; } DeactiveLastInteractible(); } else { bool setImmediateClick = false; if (interactible != PreviousInteractible) { // // bad check so we do not show the reticle over secret panel, rework when we have better password ui // if (interactible.gameObject.name != "SecretPanel") // { // _reticalOuterImage.DOFade(1.0f, 0.3f); // } StopCoroutine("GazeSelectCountdown"); CurGazeSelectionTime = GazeSelectionTime; ReticleImageSelector.fillAmount = 0.0f; SetGazeValue(0.0f); interactible.Over(); if (interactible != CurrentInteractible && CurrentInteractible != PreviousInteractible) { if (CurrentInteractible != null /*&& PreviousInteractible != null*/) { CurrentInteractible.Out(); CurrentInteractible = null; } } if (interactible.GazeSelectable) { _gazeTimer = hit.collider.gameObject.GetComponent <GazeTimer>(); _buttonController = hit.collider.transform.parent.GetComponent <ButtonController>(); if (interactible.UseGazeTime) { CurGazeSelectionTime = interactible.GazeTime; } if (interactible.TriggerImmediateClick) { setImmediateClick = true; } else { StartCoroutine("GazeSelectCountdown"); } } if (PreviousInteractible) { DeactiveLastInteractible(); } } PreviousInteractible = CurrentInteractible; CurrentInteractible = interactible; if (setImmediateClick) { HandleClick(); } } SetHitPosition(hit); } else if (hideReticeHitOccured) { if (CurrentInteractible != null && CurrentInteractible != PreviousInteractible) { CurrentInteractible.Out(); CurrentInteractible = null; } DeactiveLastInteractible(); if (!_reticleHidden) { HideReticle(); } } else if (!hideReticeHitOccured && !showLayersHitOccured) { if (CurrentInteractible != null) { CurrentInteractible.Out(); CurrentInteractible = null; } DeactiveLastInteractible(); _reticalCenterImage.DOFade(1.0f, 0.3f); _reticleHidden = false; _reticalOuterImage.DOFade(0.0f, 0.3f); Quaternion newRot = new Quaternion(); transform.position = ReticleCamera.position + ReticleCamera.forward * DefaultDistance; newRot = ReticleCamera.rotation; transform.localScale = _originalScale * DefaultDistance; transform.rotation = Quaternion.Lerp(transform.rotation, newRot, 0.2f); } }