コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
        /// <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);
            }
        }