// Update is called once per frame
 void Update()
 {
     if (controllerEvent.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TouchpadPress))
     {
         RaycastHit hit;
         //Debug.DrawRay(transform.position, transform.forward * 100, Color.red, 100);
         if (Physics.Raycast(transform.position, transform.forward * 100, out hit, 100, LM))
         {
             hit.collider.gameObject.GetComponent <UIButtonRayTargetComponent>().PointOn();
             temp = hit.collider.gameObject.GetComponent <UIButtonRayTargetComponent>();
             if (controllerEvent.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TriggerClick))
             {
                 hit.collider.gameObject.GetComponent <UIButtonRayTargetComponent>().ClickDown();
             }
             else
             {
                 hit.collider.gameObject.GetComponent <UIButtonRayTargetComponent>().ClickUp();
             }
         }
         else
         {
             if (temp != null)
             {
                 temp.PointExit();
             }
         }
     }
     else
     {
         if (temp != null)
         {
             temp.PointExit();
         }
     }
 }
 void OnPointerEnter(object sender, DestinationMarkerEventArgs e)
 {
     if (e.target.gameObject.layer != 5)
     {
         uiTouched           = false;
         tempTarget          = e.target.gameObject;
         tempTargetTransform = e.target;
         Debug.Log(vrtk_ControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TriggerPress));
     }
     else
     {
         uiTouched = true;
     }
 }
Exemplo n.º 3
0
 public void ForceDropIfNeeded()
 {
     if (!ControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress))
     {
         _vio.ForceStopInteracting();
     }
 }
Exemplo n.º 4
0
    void Update()
    {
        if (controllerEvents)
        {
            bool isTouched = controllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TouchpadTouch) ||
                             controllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TouchpadPress);

            renderer.enabled = isTouched;

            if (isTouched)
            {
                var currentAxis = controllerEvents.GetTouchpadAxis();
                transform.localPosition = new Vector3(currentAxis.x * scaleX, transform.localPosition.y, currentAxis.y * scaleZ);
            }
        }
    }
Exemplo n.º 5
0
    // Update is called once per frame
    public override void Update()
    {
        if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonOnePress))
        {
            if (currentIndex == 0)
            {
                textScreens[0].SetActive(false);
                currentIndex = 1;
                textScreens[1].SetActive(true);
            }
        }

        if (currentIndex == 1 && !isDone)
        {
            //grab super hot cube
            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress))
            {
                if (RController.GetComponent <VRTK_InteractGrab>().GetGrabbedObject() == hotCube)
                {
                    visionButton.SetActive(false);
                    grabButton.SetActive(false);
                    cubesAnim.SetBool("up", false);
                    tableAnim.SetBool("on", false);

                    isDone = true;
                    textScreens[1].SetActive(false);
                }
            }

            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress))
            {
                if (LController.GetComponent <VRTK_InteractGrab>().GetGrabbedObject() == hotCube)
                {
                    hotCube.SetActive(false);
                    coldCube.SetActive(false);
                    coldCube2.SetActive(false);
                    visionButton.SetActive(false);

                    isDone = true;
                    textScreens[1].SetActive(false);
                }
            }
        }
    }
Exemplo n.º 6
0
    void Update()
    {
        if (!acceptingUpdates)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            doUpdate();
        }
        else if (controllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.StartMenuPress))
        {
            pointer.enabled = false;

            // game is going to be paused
            if (!gameMenuCanvas.enabled)
            {
                pointer.enableTeleport         = false;
                pointer.pointerRenderer        = straightPointerRenderer;
                pointer.activationButton       = VRTK_ControllerEvents.ButtonAlias.Undefined;
                pointer.holdButtonToActivate   = false;
                bezeierPointerRenderer.enabled = false;
                uiPointer.enabled = true;
                straightPointerRenderer.enabled = true;
            }
            // game is going to be unpaused
            else if (gameMenuCanvas.enabled)
            {
                pointer.enableTeleport          = true;
                pointer.pointerRenderer         = bezeierPointerRenderer;
                pointer.activationButton        = VRTK_ControllerEvents.ButtonAlias.TouchpadPress;
                pointer.holdButtonToActivate    = true;
                straightPointerRenderer.enabled = false;
                uiPointer.enabled = false;
                bezeierPointerRenderer.enabled = true;
            }

            pointer.enabled = true;

            doUpdate();
        }
    }
Exemplo n.º 7
0
 void Update()
 {
     if (rightController != null)
     {
         if (rightController.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TriggerClick))
         {
             Debug.Log("TRIGGER");
         }
     }
 }
Exemplo n.º 8
0
 // Update is called once per frame
 void Update()
 {
     if (leftControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress) || rightControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress))
     {
         if (!buttonPressed)
         {
             active = !active;
             tutorialPage.SetActive(active);
         }
         buttonPressed = true;
     }
     else
     {
         buttonPressed = false;
     }
 }
Exemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.T))
     {
         if (controller.IsButtonPressed(VRTKSub.VRTK_ControllerEvents.ButtonAlias.TouchPad))
         {
             controller.Release(VRTKSub.VRTK_ControllerEvents.ButtonAlias.TouchPad);
         }
         else
         {
             controller.Press(VRTKSub.VRTK_ControllerEvents.ButtonAlias.TouchPad);
         }
     }
     if (Input.GetKeyDown(KeyCode.P))
     {
         StartCoroutine(controller.ClickTrigger());
     }
 }
Exemplo n.º 10
0
    void Update()
    {
        if (useKeyboard)
        {
            LeftClick = Input.GetButtonDown("Fire1");
            GetMousePos();
            GetBothShift();
            CycleSelectedObject();
            CycleSelectedItemType();
        }
        else
        {
            LeftClick = lControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TriggerPress) || rControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TriggerPress);

            Vector2 rCAxis = rControllerEvents.GetAxis(VRTK_ControllerEvents.Vector2AxisAlias.TouchpadTwo);

            if (rCAxis.x > touchpad2DeadZone)
            {
                Vector3 xMov = new Vector3(cameraTrans.right.x, 0, cameraTrans.right.z);
                playerTrans.Translate(xMov * speeeddd * Time.deltaTime);
            }

            if (rCAxis.x < -touchpad2DeadZone)
            {
                Vector3 xMov = new Vector3(cameraTrans.right.x, 0, cameraTrans.right.z);
                playerTrans.Translate(-xMov * speeeddd * Time.deltaTime);
            }

            if (rCAxis.y > touchpad2DeadZone)
            {
                Vector3 yMov = new Vector3(cameraTrans.forward.x, 0, cameraTrans.forward.z);
                playerTrans.Translate(yMov * speeeddd * Time.deltaTime);
            }

            if (rCAxis.y < -touchpad2DeadZone)
            {
                Vector3 yMov = new Vector3(cameraTrans.forward.x, 0, cameraTrans.forward.z);
                playerTrans.Translate(-yMov * speeeddd * Time.deltaTime);
            }
        }
    }
Exemplo n.º 11
0
    void Update()
    {
        if (!phone.IsGrabbed())
        {
            return;
        }

        if (controllerEvents.IsButtonPressed(button))
        {
            time += Time.deltaTime;

            if (time >= requiredHeldTime)
            {
                disableOnTurnOff.SetActive(false);
            }
        }
        else
        {
            time = 0;
        }
    }
    private void Update()
    {
        if (!controllerEvents)
        {
            return;
        }

        bool isTouched = controllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TouchpadTouch) ||
                         controllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TouchpadPress);

        var currentAxis = controllerEvents.GetTouchpadAxis();

        if (isTouched && !wasTouched)
        {
            skippedBadInput    = 0;
            lastDir            = 0;
            scrollAmount       = Vector2.zero;
            lastPosition       = currentAxis;
            touchStartPosition = currentAxis;
            touchStartTime     = Time.time;
            StopAllCoroutines();
        }
        else if (!isTouched && wasTouched)
        {
            var touchEndTime = Time.time;
            var touchTime    = touchEndTime - touchStartTime;

            if (touchTime > 0)
            {
                var swipeVector = lastPosition - touchStartPosition;
                var velocity    = swipeVector.magnitude / touchTime;

                if (velocity >= scrollThreshold)
                {
                    var scrollDir = new Vector2(0, Mathf.Sign(swipeVector.y) * invertMultiplier);

                    StartCoroutine(DoScroll(velocity * swipeScale, scrollDir));
                }
            }
        }

        if (isTouched)
        {
            scrollAmount = currentAxis - lastPosition;
            float currentDirection = Mathf.Sign(scrollAmount.y);

            if (Mathf.Abs(scrollAmount.y) >= scrollThreshold)
            {
                if (lastDir != 0 && currentDirection != lastDir && skippedBadInput < numberBadChecks)
                {
                    skippedBadInput++;
                    return;
                }

                skippedBadInput = 0;
                lastPosition    = currentAxis;

                OnScroll(scrollAmount * scrollScale * invertMultiplier);
            }
        }

        wasTouched = isTouched;
    }
Exemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        if (textScreens[1].activeSelf)                         // on button screen
        {
            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonOnePress))
            {
                R1.SetActive(false);                 // turn off glow on R button 1
            }
            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress))
            {
                R2.SetActive(false);                 // turn off glow on R button 2
            }
            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonOnePress))
            {
                L1.SetActive(false);                 // turn off glow on L button 1
            }
            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress))
            {
                L2.SetActive(false);                 // turn off glow on L button 2
            }

            // once all buttons are pressed
            if (!R1.activeSelf && !R2.activeSelf && !L1.activeSelf && !L2.activeSelf)
            {
                // move to next screen
                textScreens[1].SetActive(false);
                textScreens[2].SetActive(true);

                // turn on trigger glow
                RTrigger.SetActive(true);
                LTrigger.SetActive(true);
            }
        }
        else if (textScreens[2].activeSelf)                         // on trigger screen
        {
            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TriggerPress))
            {
                RTrigger.SetActive(false);                 // turn off glow on R trigger
            }
            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TriggerPress))
            {
                LTrigger.SetActive(false);                 // turn off glow on L trigger
            }

            // once both triggers are pressed
            if (!RTrigger.activeSelf && !LTrigger.activeSelf)
            {
                // move to next screen
                textScreens[2].SetActive(false);
                textScreens[3].SetActive(true);

                // turn on grip glow
                RGrip.SetActive(true);
                LGrip.SetActive(true);
            }
        }
        else if (textScreens[3].activeSelf)                         // on grip screen
        {
            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress))
            {
                RGrip.SetActive(false);                 // turn off glow on R grip
            }
            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress))
            {
                LGrip.SetActive(false);                 // turn off glow on L grip
            }

            // once both grips are pressed
            if (!RGrip.activeSelf && !LGrip.activeSelf)
            {
                // move to next screen
                textScreens[3].SetActive(false);
                textScreens[4].SetActive(true);

                // turn on table and goggles
                table.SetActive(true);
                goggles.SetActive(true);

                // turn on components to grab
                RController.GetComponent <VRTK_InteractGrab>().enabled  = true;
                RController.GetComponent <VRTK_InteractTouch>().enabled = true;
            }
        }
        else if (textScreens[4].activeSelf)             // on grab screen
        {
            //grab goggles
            if (goggles == null)
            {
                // move to next screen
                textScreens[4].SetActive(false);
                textScreens[5].SetActive(true);

                superHotCube.SetActive(true);
                coolCube1.SetActive(true);
                coolCube2.SetActive(true);
            }
        }
        else if (textScreens[5].activeSelf)
        {
            //switch visions
            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonOnePress))
            {
                changeVisions();
                // move to next screen
                textScreens[5].SetActive(false);
                textScreens[6].SetActive(true);
            }
        }
        else if (textScreens[6].activeSelf)
        {
            //grab super hot cube
            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonOnePress))
            {
                changeVisions();
            }

            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress))
            {
                if (RController.GetComponent <VRTK_InteractGrab>().GetGrabbedObject() == superHotCube)
                {
                    textScreens[6].SetActive(false);
                    textScreens[7].SetActive(true);

                    superHotCube.SetActive(false);
                    coolCube1.SetActive(false);
                    coolCube2.SetActive(false);
                }
            }

            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress))
            {
                if (LController.GetComponent <VRTK_InteractGrab>().GetGrabbedObject() == superHotCube)
                {
                    textScreens[6].SetActive(false);
                    textScreens[7].SetActive(true);

                    superHotCube.SetActive(false);
                    coolCube1.SetActive(false);
                    coolCube2.SetActive(false);
                }
            }
        }
        else if (textScreens[7].activeSelf)                             // on teleport screen
        {
            foreach (GameObject platform in platforms)
            {
                platform.SetActive(true);
                door.SetActive(true);
                RController.GetComponent <VRTK_Pointer>().enabled = true;
                RController.GetComponent <VRTK_StraightPointerRenderer>().enabled = true;
            }
        }
    }
Exemplo n.º 14
0
    // Update is called once per frame
    public override void Update()
    {
        if (currentIndex == 1)           // on button screen
        {
            GameObject R1 = (GameObject)(buttonsHashed[HashKeys.RIGHT_BUTTON1]);
            GameObject R2 = (GameObject)(buttonsHashed[HashKeys.RIGHT_BUTTON2]);
            GameObject L1 = (GameObject)(buttonsHashed[HashKeys.LEFT_BUTTON1]);
            GameObject L2 = (GameObject)(buttonsHashed[HashKeys.LEFT_BUTTON2]);

            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonOnePress))
            {
                R1.SetActive(false);                 // turn off glow on R button 1
            }
            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress))
            {
                R2.SetActive(false);                 // turn off glow on R button 2
            }
            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonOnePress))
            {
                L1.SetActive(false);                 // turn off glow on L button 1
            }
            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress))
            {
                L2.SetActive(false);                 // turn off glow on L button 2
            }

            // once all buttons are pressed
            if (!R1.activeSelf && !R2.activeSelf && !L1.activeSelf && !L2.activeSelf)
            {
                // move to next screen
                textScreens[1].SetActive(false);
                textScreens[2].SetActive(true);

                currentIndex = 2;

                ((GameObject)buttonsHashed[HashKeys.LEFT_TRIGGER]).SetActive(true);
                ((GameObject)buttonsHashed[HashKeys.RIGHT_TRIGGER]).SetActive(true);
            }
        }
        else if (currentIndex == 2)             // on trigger screen
        {
            GameObject RTrigger = (GameObject)buttonsHashed[HashKeys.RIGHT_TRIGGER];
            GameObject LTrigger = (GameObject)buttonsHashed[HashKeys.LEFT_TRIGGER];

            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TriggerPress))
            {
                RTrigger.SetActive(false);                 // turn off glow on R trigger
            }
            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TriggerPress))
            {
                LTrigger.SetActive(false);                 // turn off glow on L trigger
            }

            // once both triggers are pressed
            if (!RTrigger.activeSelf && !LTrigger.activeSelf)
            {
                // move to next screen
                textScreens[2].SetActive(false);
                textScreens[3].SetActive(true);

                currentIndex = 3;

                ((GameObject)buttonsHashed[HashKeys.LEFT_GRIP]).SetActive(true);
                ((GameObject)buttonsHashed[HashKeys.RIGHT_GRIP]).SetActive(true);
            }
        }
        else if (currentIndex == 3)         // on grip screen
        {
            GameObject RGrip = (GameObject)buttonsHashed[HashKeys.RIGHT_GRIP];
            GameObject LGrip = (GameObject)buttonsHashed[HashKeys.LEFT_GRIP];

            if (RControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress))
            {
                RGrip.SetActive(false);                 // turn off glow on R grip
            }
            if (LControllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.GripPress))
            {
                LGrip.SetActive(false);                 // turn off glow on L grip
            }

            // once both grips are pressed
            if (!RGrip.activeSelf && !LGrip.activeSelf)
            {
                // move to next screen
                textScreens[3].SetActive(false);
                isDone = true;
            }
        }
    }