Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (choiceSelected == false)
     {
         if (circularProgressBarSelectorInstance.GetProgress() == 1.0f)
         {
             GameObject selection = circularProgressBarSelectorInstance.GetCurrentLookedAtItem();
             choiceSelected = true;
             experimentManager.ChangeToNextScene();
         }
     }
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        // Do nothing if user already confirmed choice
        if (choiceSelected == true)
        {
            return;
        }

        // See if user is trying to confirm their selection
        if (controllers[0].GetHairTrigger() && controllers[1].GetHairTrigger())
        {
            // Prevent user from clicking too early (there's a cooldown between scene change)
            if (experimentManager.ChangeToNextScene())
            {
                choiceSelected = true;
                SaveResultToFile(experimentManager.GetLoggingDirectory(), (rectangularProgressBarInstance.GetProgress() * 100.0f).ToString());
                return;
            }
        }

        // Update progress bar accordingly
        for (int i = 0; i < 2; i++)
        {
            // Detect if finger is on trackpad
            SteamVR_Controller.Device device = controllers[i];
            if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
            {
                // Get touch pad value and handle case where user's input was not continuous
                Vector2 touchpad = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad);
                if (lastTouchTrackPad[i] == false)
                {
                    lastTrackPadValues[i] = touchpad;
                }

                // Update progress bar
                float currentProgress = rectangularProgressBarInstance.GetProgress();
                rectangularProgressBarInstance.SetProgress(currentProgress + (touchpad.x - lastTrackPadValues[i].x) * sensitivity);
                lastTrackPadValues[i] = touchpad;
            }
            lastTouchTrackPad[i] = device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad);
        }

        userInputUi.text = (int)(rectangularProgressBarInstance.GetProgress() * 100.0f) + "%";
    }