Example #1
0
    // Update is called once per frame
    void Update()
    {
        //Hide menu if user attempts to teleport
        if (SteamVR_Input._default.inActions.Teleport.GetStateDown(SteamVR_Input_Sources.RightHand))
        {
            objectMenuManager.HideMenu();
        }

        if (SteamVR_Input._default.inActions.DisplayObjectMenu.GetStateDown(SteamVR_Input_Sources.RightHand))
        {
            objectMenuManager.ToggleMenu();
        }

        //displayMenu = SteamVR_Input._default.inActions.DisplayObjectMenu;
        //if (SteamVR_Input._default.inActions.DisplayObjectMenu.GetStateDown(SteamVR_Input_Sources.LeftHand)) {
        Vector2 touchCurrent = joyStickAction.GetAxis(SteamVR_Input_Sources.RightHand);

        if (!hasSwipedRight)
        {
            if (touchCurrent.x > 0.5)
            {
                SwipeRight();
                hasSwipedRight = true;
                hasSwipedLeft  = false;
            }
        }

        if (!hasSwipedLeft)
        {
            if (touchCurrent.x < -0.5)
            {
                SwipeLeft();
                hasSwipedLeft  = true;
                hasSwipedRight = false;
            }
        }

        if (touchCurrent.y < -0.5)
        {
            SwipeDown();
        }
        if (touchCurrent.y > 0.5)
        {
            SwipeUp();
        }

        if (touchCurrent.x == 0)
        {
            hasSwipedLeft  = false;
            hasSwipedRight = false;
        }

        if (SteamVR_Input._default.inActions.DisplayObjectMenu.GetStateUp(SteamVR_Input_Sources.RightHand))
        {
            objectMenuManager.ToggleMenu();
        }

        if (SteamVR_Input._default.inActions.GrabPinch.GetStateDown(SteamVR_Input_Sources.RightHand))
        {
            SpawnObject();
        }

        Vector2 leftTouchCurrent = joyStickAction.GetAxis(SteamVR_Input_Sources.LeftHand);

        if (leftTouchCurrent.x > 0.5)
        {
            RotateClockWise();
        }

        if (leftTouchCurrent.x < -0.5)
        {
            RotateAntiClockWise();
        }
    }
Example #2
0
 // Update is called once per frame
 void Update()
 {
     device = SteamVR_Controller.Input((int)trackedObj.index);
     if (device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu) && !menuHide)
     {
         menuInstructions.SetActive(false);
         menuHide = true;
     }
     else
     {
         if (objectMenuManager != null)
         {
             if (device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu) && menuHide)
             {
                 if (isOpen)
                 {
                     objectMenuManager.HideMenu();
                     isOpen = false;
                 }
                 else
                 {
                     objectMenuManager.DisplayMenu();
                     isOpen = true;
                 }
             }
             if (objectMenuManager.gameObject.activeInHierarchy)
             {
                 if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
                 {
                     touchLast  = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;
                     touchLastY = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).y;
                 }
                 if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
                 {
                     touchCurrent  = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;
                     touchCurrentY = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).y;
                     distance      = touchCurrent - touchLast;
                     touchLast     = touchCurrent;
                     swipeSum     += distance;
                     if (!hasSwipedRight)
                     {
                         if (touchCurrent > 0f && touchCurrentY > -0.2f)
                         {
                             swipeSum = 0;
                             SwipeRight();
                             hasSwipedRight = true;
                             hasSwipedLeft  = false;
                         }
                     }
                     if (!hasSwipedLeft)
                     {
                         if (touchCurrent < 0f && touchCurrentY > -0.2f)
                         {
                             swipeSum = 0;
                             SwipeLeft();
                             hasSwipedLeft  = true;
                             hasSwipedRight = false;
                         }
                     }
                 }
                 if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
                 {
                     swipeSum       = 0;
                     touchCurrent   = 0;
                     touchLast      = 0;
                     hasSwipedLeft  = false;
                     hasSwipedRight = false;
                 }
                 if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
                 {
                     if (touchCurrentY < 0f)
                     {
                         SpawnObject();
                     }
                     //Spawn object currently selected by menu
                 }
             }
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        device = SteamVR_Controller.Input((int)trackedObj.index);

        if (objectMenuManager == null)
        {
            return;
        }

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            objectMenuManager.ShowMenu();
            //touchLast = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;
        }
        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            // if the user presses the left half of the touchpad
            if (device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x < 0)
            {
                //Debug.Log("pressing on" + device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x);
                SwipeLeft();
                hasPressedLeft  = true;
                hasPressedRight = false;
            }

            // if the user presses the right half of the touchpad
            if (device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x > 0)
            {
                //Debug.Log("pressing on" + device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x);
                SwipeRight();
                hasPressedLeft  = false;
                hasPressedRight = true;
            }


            //only accessing x horizontal value of touchpad

            /*
             * touchCurrent = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;
             * distance = touchCurrent - touchLast;
             * touchLast = touchCurrent;
             * swipeSum += distance;
             */


/*
 *          if (!hasSwipedRight)
 *          {
 *              if (swipeSum > 0.5f)
 *              {
 *                  swipeSum = 0;
 *                  SwipeRight();
 *                  hasSwipedRight = true;
 *                  hasSwipedLeft = false;
 *              }
 *          }
 *          if(!hasSwipedLeft)
 *          {
 *              if (swipeSum < -0.5f)
 *              {
 *                  swipeSum = 0;
 *                  SwipeLeft();
 *                  hasSwipedRight = false;
 *                  hasSwipedLeft = true;
 *
 *              }
 *          }
 */
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            swipeSum        = 0;
            touchCurrent    = 0;
            touchLast       = 0;
            hasPressedLeft  = false;
            hasPressedRight = false;
            objectMenuManager.HideMenu();
        }

        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger) && objectMenuManager.GetMenuActiveState() == true)
        {
            // spawn object selected by menu
            SpawnObject();
        }
    }