private IEnumerator Hold_CR() { exitRenderer.enabled = true; bool success = true; float time = 0f; while (time < exitInterval) { time += Time.deltaTime; exitRenderer.material.SetFloat("_Angle", Mathf.Lerp(-Mathf.PI, Mathf.PI, Mathf.Clamp01(time / exitInterval))); #if UNITY_EDITOR if (Input.GetMouseButtonUp(0)) { success = false; break; } #else foreach (var touch in Input.touches) { if (touch.phase == TouchPhase.Ended) { success = false; break; } } if (!success) { break; } #endif yield return(null); } if (success) { stage = PracticeStage.After; _transitionRecord.Add(new KeyValuePair <float, int>(Time.time - PresentationData.in_EnterTime, player.CurrIdx)); if (OnPracticeEnd != null) { OnPracticeEnd(); } exitRenderer.enabled = false; yield return(new WaitForSeconds(2f)); _startDetect = false; } else { _startDetect = false; exitRenderer.enabled = false; } }
private void Start() { if (ctrlType == SlidesCtrlType.Trigger) { #if !UNITY_EDITOR && UNITY_ANDROID Cardboard.SDK.OnTrigger += OnTriggerPulled; #endif } else if (ctrlType == SlidesCtrlType.AutoAdvance) StartCoroutine(AutoAdvance_CR()); _transitionRecord = new List<KeyValuePair<float, int>>(); _transitionRecord.Add(new KeyValuePair<float, int>(0f, 0)); player.Play(); exitRenderer.enabled = false; stage = PracticeStage.Before; }
private IEnumerator ForcePracticeEnd_CR() { if (stage == PracticeStage.Practicing) { _startDetect = true; stage = PracticeStage.After; _transitionRecord.Add(new KeyValuePair <float, int>(Time.time - PresentationData.in_EnterTime, player.CurrIdx)); if (OnPracticeEnd != null) { OnPracticeEnd(); } exitRenderer.enabled = false; yield return(new WaitForSeconds(2f)); _startDetect = false; } }
private void Start() { if (ctrlType == SlidesCtrlType.Trigger) { #if !UNITY_EDITOR && UNITY_ANDROID Cardboard.SDK.OnTrigger += OnTriggerPulled; #endif } else if (ctrlType == SlidesCtrlType.AutoAdvance) { StartCoroutine(AutoAdvance_CR()); } _transitionRecord = new List <KeyValuePair <float, int> >(); _transitionRecord.Add(new KeyValuePair <float, int>(0f, 0)); player.Play(); exitRenderer.enabled = false; stage = PracticeStage.Before; }
private IEnumerator DoubleClick_CR() { int touchCounter = 0; float time = 0f; while (time < doubleClickInterval) { #if UNITY_EDITOR if (Input.GetMouseButtonUp(0)) touchCounter++; #else foreach (var touch in Input.touches) { if (touch.phase == TouchPhase.Ended) touchCounter++; } #endif time += Time.deltaTime; yield return null; } switch (stage) { case PracticeStage.Before: { stage = PracticeStage.Practicing; if (OnPracticeBegin != null) OnPracticeBegin(); _startDetect = false; break; } case PracticeStage.Practicing: { if (touchCounter == 1) //single touches { if (player.NextSlide()) _transitionRecord.Add(new KeyValuePair<float, int>(Time.time - PresentationData.in_EnterTime, player.CurrIdx)); _startDetect = false; } else if (touchCounter > 1) //double touches { if (player.PrevSlide()) _transitionRecord.Add(new KeyValuePair<float, int>(Time.time - PresentationData.in_EnterTime, player.CurrIdx)); _startDetect = false; } else { //hold yield return StartCoroutine(Hold_CR()); } break; } case PracticeStage.After: default: { if (OnExitVRScene != null) OnExitVRScene(); _startDetect = false; break; } } }
private IEnumerator ForcePracticeEnd_CR() { if (stage == PracticeStage.Practicing) { _startDetect = true; stage = PracticeStage.After; _transitionRecord.Add(new KeyValuePair<float, int>(Time.time - PresentationData.in_EnterTime, player.CurrIdx)); if (OnPracticeEnd != null) OnPracticeEnd(); exitRenderer.enabled = false; yield return new WaitForSeconds(2f); _startDetect = false; } }
private IEnumerator Hold_CR() { exitRenderer.enabled = true; bool success = true; float time = 0f; while (time < exitInterval) { time += Time.deltaTime; exitRenderer.material.SetFloat("_Angle", Mathf.Lerp(-Mathf.PI, Mathf.PI, Mathf.Clamp01(time / exitInterval))); #if UNITY_EDITOR if (Input.GetMouseButtonUp(0)) { success = false; break; } #else foreach (var touch in Input.touches) { if (touch.phase == TouchPhase.Ended) { success = false; break; } } if (!success) break; #endif yield return null; } if (success) { stage = PracticeStage.After; _transitionRecord.Add(new KeyValuePair<float, int>(Time.time - PresentationData.in_EnterTime, player.CurrIdx)); if (OnPracticeEnd != null) OnPracticeEnd(); exitRenderer.enabled = false; yield return new WaitForSeconds(2f); _startDetect = false; } else { _startDetect = false; exitRenderer.enabled = false; } }
private IEnumerator DoubleClick_CR() { int touchCounter = 0; float time = 0f; while (time < doubleClickInterval) { #if UNITY_EDITOR if (Input.GetMouseButtonUp(0)) { touchCounter++; } #else foreach (var touch in Input.touches) { if (touch.phase == TouchPhase.Ended) { touchCounter++; } } #endif time += Time.deltaTime; yield return(null); } switch (stage) { case PracticeStage.Before: { stage = PracticeStage.Practicing; if (OnPracticeBegin != null) { OnPracticeBegin(); } _startDetect = false; break; } case PracticeStage.Practicing: { if (touchCounter == 1) //single touches { if (player.NextSlide()) { _transitionRecord.Add(new KeyValuePair <float, int>(Time.time - PresentationData.in_EnterTime, player.CurrIdx)); } _startDetect = false; } else if (touchCounter > 1) //double touches { if (player.PrevSlide()) { _transitionRecord.Add(new KeyValuePair <float, int>(Time.time - PresentationData.in_EnterTime, player.CurrIdx)); } _startDetect = false; } else { //hold yield return(StartCoroutine(Hold_CR())); } break; } case PracticeStage.After: default: { if (OnExitVRScene != null) { OnExitVRScene(); } _startDetect = false; break; } } }