/// <summary> /// Check if camera is pointing at any key. /// If it does changes state of key /// </summary> private void RayCastKeyboard() { ray = new Ray(raycastingSource.position, raycastingSource.forward); if (Physics.Raycast(ray, out hit, rayLength, layer)) // If any key was hit { KeyboardItem focusedKeyItem = hit.transform.gameObject.GetComponent <KeyboardItem>(); if (focusedKeyItem != null) // Hit may occur on item without script { ChangeCurrentKeyItem(focusedKeyItem); keyItemCurrent.Hovering(); #if !UNITY_HAS_GOOGLEVR if (Input.GetButtonDown(clickInputName)) // If key clicked { #else if (Input.GetMouseButtonDown(0)) { #endif keyItemCurrent.Click(); keyboardStatus.HandleClick(keyItemCurrent); } } } else if (keyItemCurrent != null) // If no target hit and lost focus on item { ChangeCurrentKeyItem(null); } }
/// <summary> /// Check if camera is pointing at any key. /// If it does changes state of key /// </summary> private void RayCastKeyboard() { ray = new Ray(raycastingSource.position, raycastingSource.forward); if (Physics.Raycast(ray, out hit, rayLength, layer)) // If any key was hit { KeyboardItem focusedKeyItem = hit.transform.gameObject.GetComponent <KeyboardItem>(); if (focusedKeyItem != null) // Hit may occur on item without script { ChangeCurrentKeyItem(focusedKeyItem); keyItemCurrent.Hovering(); if (focusedKeyItem.letter.text == "a") { if (sceneName != "SceneA") { SceneManager.LoadScene("SceneA"); } } if (focusedKeyItem.letter.text == "b") { if (sceneName != "SceneC") { SceneManager.LoadScene("SceneC"); } } if (focusedKeyItem.letter.text == "c") { if (sceneName != "SceneD") { SceneManager.LoadScene("SceneD"); } } } } else if (keyItemCurrent != null) // If no target hit and lost focus on item { ChangeCurrentKeyItem(null); } }
/// <summary> /// Check if camera is pointing at any key. /// If it does changes state of key /// </summary> private void RayCastKeyboard() { ray = new Ray(raycastingSource.position, raycastingSource.forward); if (Physics.Raycast(ray, out hit, rayLength, layer)) // If any key was hit { KeyboardItem focusedKeyItem = hit.transform.gameObject.GetComponent <KeyboardItem>(); if (focusedKeyItem != null) // Hit may occur on item without script { ChangeCurrentKeyItem(focusedKeyItem); keyItemCurrent.Hovering(); if (buttons != null) { if (!tp) { if (buttons.triggerPressed) {// If key clicked tp = true; keyItemCurrent.Click(); keyboardStatus.HandleClick(keyItemCurrent); } } else { if (!buttons.triggerPressed) { tp = false; } } } else { keyItemCurrent.Click(); keyboardStatus.HandleClick(keyItemCurrent); } } } else if (keyItemCurrent != null) // If no target hit and lost focus on item { ChangeCurrentKeyItem(null); } }
/// <summary> /// Check if camera is pointing at any key. /// If it does changes state of key /// </summary> private void RayCastKeyboard() { ray = new Ray(raycastingSource.position, raycastingSource.forward); if (Physics.Raycast(ray, out hit, rayLength, layer)) // If any key was hit { KeyboardItem focusedKeyItem = hit.transform.gameObject.GetComponent <KeyboardItem>(); if (focusedKeyItem != null) // Hit may occur on item without script { ChangeCurrentKeyItem(focusedKeyItem); keyItemCurrent.Hovering(); #if !UNITY_HAS_GOOGLEVR //former: if(Input.GetButtonDown(clickInputName)) if (controller.GetComponent <VRTK.VRTK_InteractGrab>().IsGrabButtonPressed()) { // If key clicked #else if (GvrController.TouchDown) { #endif //If the user has clicked, //debounce is false, it is not a duplicate click as a result of the update cycle if (debounce == false) { keyItemCurrent.Click(); keyboardStatus.HandleClick(keyItemCurrent); } debounce = true; //set true, because this click has already been used. } else { debounce = false; //user ended previous click } } } else if (keyItemCurrent != null) // If no target hit and lost focus on item { ChangeCurrentKeyItem(null); } }