private void OnTriggeGaze() { bool sendEvent = false; // The gameobject to which raycast positions var currentOverGO = pointerData.pointerCurrentRaycast.gameObject; // { ------- Reticle -------- if (progressText == null) { GameObject pt = GameObject.Find("ProgressText"); if (pt != null) { progressText = pt.GetComponent <Text>(); } } if (counterText == null) { GameObject ct = GameObject.Find("CounterText"); if (ct != null) { counterText = ct.GetComponent <Text>(); } } if (pointerData.pointerEnter == null && currentOverGO == null) { UpdateReticle(currentOverGO, pointerData); progressflag = true; if (progressText != null) { progressText.text = ""; } if (counterText != null) { counterText.text = ""; } if (gazePointer != null) { gazePointer.triggerProgressBar(false); } return; } if (!progressRate && !progressCounter) // if no counting, reset trigger flag { progressflag = true; } if (!progressRate || !progressCounter) // clear counting content { if (progressText != null && progressText.text != "") { progressText.text = ""; } if (counterText != null && counterText.text != "") { counterText.text = ""; } } // --------- Reticle -------- } if (pointerData.pointerEnter != currentOverGO) { #if UNITY_EDITOR PrintDebugLog("OnTriggeGaze() pointerEnter: " + pointerData.pointerEnter + ", currentOverGO: " + currentOverGO); #endif HandlePointerExitAndEnter(pointerData, currentOverGO); gazeTime = Time.unscaledTime; // { ------- Reticle -------- countingTime = Time.unscaledTime; UpdateReticle(currentOverGO, pointerData); // --------- Reticle -------- } } else { // { ------- Reticle -------- if (progressflag) // begin to count, do initialization { if (gazePointer != null) { gazePointer.triggerProgressBar(true); } if (progressRate && progressText != null) { progressText.text = "0%"; } if (progressCounter && counterText != null) { counterText.text = TimeToGaze.ToString(); } countingTime = Time.unscaledTime; progressflag = false; // counting the rate of waiting for clicking event } // --------- Reticle -------- } float elapsedTime = Time.unscaledTime; if (BtnControl && !WithTimeGaze) { UpdateBtnState(); if (btnPressDown) { sendEvent = true; } if (progressRate) { if (progressText != null) { progressText.text = ""; } } if (progressCounter) { if (counterText != null) { counterText.text = ""; } } if (gazePointer != null) { gazePointer.triggerProgressBar(false); } progressflag = false; } else { if (BtnControl && WithTimeGaze) { UpdateBtnState(); if (btnPressDown) { gazeTime = Time.unscaledTime - TimeToGaze; } } if (elapsedTime - gazeTime > TimeToGaze) { #if UNITY_EDITOR //PrintDebugLog ("OnTriggeGaze() Selected: {" + currentOverGO.name + "} over " + TimeToGaze + " seconds."); #endif sendEvent = true; gazeTime = Time.unscaledTime; // { ------- Reticle -------- if (progressRate) { if (progressText != null) { progressText.text = ""; } } if (progressCounter) { if (counterText != null) { counterText.text = ""; } } if (gazePointer != null) { gazePointer.triggerProgressBar(false); } progressflag = true; // reset trigger flag after each counting is done } else { float rate = ((Time.unscaledTime - gazeTime) / TimeToGaze) * 100; if (gazePointer != null) { gazePointer.setProgressBarTime(rate); } if (progressRate) { if (progressText != null) { progressText.text = Mathf.Floor(rate) + "%"; } } if (progressCounter) { if (counterText != null) { counterText.text = System.Math.Round(TimeToGaze - (Time.unscaledTime - countingTime), 2).ToString(); } } // --------- Reticle -------- } } } } // Standalone Input Module information pointerData.delta = Vector2.zero; pointerData.dragging = false; DeselectIfSelectionChanged(currentOverGO, pointerData); if (sendEvent) { if (InputEvent == EGazeInputEvent.PointerClick) { ExecuteEvents.ExecuteHierarchy(currentOverGO, pointerData, ExecuteEvents.pointerClickHandler); pointerData.clickTime = Time.unscaledTime; } else if (InputEvent == EGazeInputEvent.PointerDown) { // like "mouse" action, press->release soon, do NOT keep the pointerPressRaycast cause do NOT need to controll "down" object while not gazing. pointerData.pressPosition = pointerData.position; pointerData.pointerPressRaycast = pointerData.pointerCurrentRaycast; var _pointerDownGO = ExecuteEvents.ExecuteHierarchy(currentOverGO, pointerData, ExecuteEvents.pointerDownHandler); ExecuteEvents.ExecuteHierarchy(_pointerDownGO, pointerData, ExecuteEvents.pointerUpHandler); } else if (InputEvent == EGazeInputEvent.PointerSubmit) { ExecuteEvents.ExecuteHierarchy(currentOverGO, pointerData, ExecuteEvents.submitHandler); } } }
private void OnTriggeGaze() { // The gameobject to which raycast positions var currentOverGO = pointerData.pointerCurrentRaycast.gameObject; UpdateReticle(currentOverGO, pointerData); bool sendEvent = false; this.HmdEnterPressDown = WaveVR_Controller.Input(WaveVR_Controller.EDeviceType.Head).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Enter); if (this.HmdEnterPressDown) { sendEvent = true; } if (pointerData.pointerEnter != currentOverGO) { PrintDebugLog("OnTriggeGaze() pointerEnter: " + pointerData.pointerEnter + ", currentOverGO: " + currentOverGO); HandlePointerExitAndEnter(pointerData, currentOverGO); if (currentOverGO != null) { gazeTime = this.currUnscaledTime; } } else { if (currentOverGO != null) { if (gazePointer != null) { gazePointer.triggerProgressBar(true); } if (this.currUnscaledTime - gazeTime > TimeToGaze) { sendEvent = true; gazeTime = this.currUnscaledTime; } else { float rate = ((this.currUnscaledTime - gazeTime) / TimeToGaze) * 100; if (gazePointer != null) { gazePointer.setProgressBarTime(rate); } } if (this.BtnControl) { if (!this.WithTimeGaze) { gazeTime = this.currUnscaledTime; gazePointer.triggerProgressBar(false); } UpdateButtonStates(); if (btnPressDown) { sendEvent = true; this.gazeTime = this.currUnscaledTime; } } } else { if (gazePointer != null) { gazePointer.triggerProgressBar(false); } } } // Standalone Input Module information pointerData.delta = Vector2.zero; pointerData.dragging = false; DeselectIfSelectionChanged(currentOverGO, pointerData); if (sendEvent) { PrintDebugLog("OnTriggeGaze() selected " + currentOverGO.name); if (InputEvent == EGazeInputEvent.PointerClick) { ExecuteEvents.ExecuteHierarchy(currentOverGO, pointerData, ExecuteEvents.pointerClickHandler); pointerData.clickTime = this.currUnscaledTime; } else if (InputEvent == EGazeInputEvent.PointerDown) { // like "mouse" action, press->release soon, do NOT keep the pointerPressRaycast cause do NOT need to controll "down" object while not gazing. pointerData.pressPosition = pointerData.position; pointerData.pointerPressRaycast = pointerData.pointerCurrentRaycast; var _pointerDownGO = ExecuteEvents.ExecuteHierarchy(currentOverGO, pointerData, ExecuteEvents.pointerDownHandler); ExecuteEvents.ExecuteHierarchy(_pointerDownGO, pointerData, ExecuteEvents.pointerUpHandler); } else if (InputEvent == EGazeInputEvent.PointerSubmit) { ExecuteEvents.ExecuteHierarchy(currentOverGO, pointerData, ExecuteEvents.submitHandler); } } }
private void OnTriggeGaze() { UpdateReticle(preGazeObject, pointerData); // The gameobject to which raycast positions var curGazeObject = pointerData.pointerCurrentRaycast.gameObject; bool isInteractive = pointerData.pointerPress != null || ExecuteEvents.GetEventHandler <IPointerClickHandler>(curGazeObject) != null; bool sendEvent = false; this.HmdEnterPressDown = WaveVR_Controller.Input(WaveVR_Controller.EDeviceType.Head).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Enter); if (this.HmdEnterPressDown) { sendEvent = true; } EnterExitGraphicObject(); EnterExitPhysicsObject(); if (preGazeObject != curGazeObject) { DEBUG("preGazeObject: " + (preGazeObject != null ? preGazeObject.name : "null") + ", curGazeObject: " + (curGazeObject != null ? curGazeObject.name : "null")); if (curGazeObject != null) { gazeTime = this.currUnscaledTime; } } else { if (curGazeObject != null) { if (useWaveVRReticle && gazePointer != null) { gazePointer.triggerProgressBar(true); } if (this.TimerControl) { if (this.currUnscaledTime - gazeTime > TimeToGaze) { sendEvent = true; gazeTime = this.currUnscaledTime; } float rate = ((this.currUnscaledTime - gazeTime) / TimeToGaze) * 100; if (useWaveVRReticle && gazePointer != null) { gazePointer.setProgressBarTime(rate); } else { if (ringMesh != null) { ringMesh.RingPercent = isInteractive ? (int)rate : 0; } } } if (this.ButtonControl) { if (!this.TimerControl) { if (useWaveVRReticle && gazePointer != null) { gazePointer.triggerProgressBar(false); } else { if (ringMesh != null) { ringMesh.RingPercent = 0; } } } UpdateButtonStates(); if (btnPressDown) { sendEvent = true; this.gazeTime = this.currUnscaledTime; } } } else { if (useWaveVRReticle && gazePointer != null) { gazePointer.triggerProgressBar(false); } else { if (ringMesh != null) { ringMesh.RingPercent = 0; } } } } // Standalone Input Module information pointerData.delta = Vector2.zero; pointerData.dragging = false; DeselectIfSelectionChanged(curGazeObject, pointerData); if (sendEvent) { DEBUG("OnTriggeGaze() selected " + curGazeObject.name); if (InputEvent == EGazeInputEvent.PointerClick) { ExecuteEvents.ExecuteHierarchy(curGazeObject, pointerData, ExecuteEvents.pointerClickHandler); pointerData.clickTime = this.currUnscaledTime; } else if (InputEvent == EGazeInputEvent.PointerDown) { // like "mouse" action, press->release soon, do NOT keep the pointerPressRaycast cause do NOT need to controll "down" object while not gazing. pointerData.pressPosition = pointerData.position; pointerData.pointerPressRaycast = pointerData.pointerCurrentRaycast; var _pointerDownGO = ExecuteEvents.ExecuteHierarchy(curGazeObject, pointerData, ExecuteEvents.pointerDownHandler); ExecuteEvents.ExecuteHierarchy(_pointerDownGO, pointerData, ExecuteEvents.pointerUpHandler); } else if (InputEvent == EGazeInputEvent.PointerSubmit) { ExecuteEvents.ExecuteHierarchy(curGazeObject, pointerData, ExecuteEvents.submitHandler); } } }