Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (fade)
        {
            if (headsetFade.IsFaded())
            {
                fade = false;
            }
        }

        if (!fade && headsetFade.IsFaded())
        {
            player.position = new Vector3(0, 0, 0);
            headsetFade.Unfade(3);
            titlePlane.SetActive(false);
            playOnTrigger.Resume();

            if (fadeCount >= 2)
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            Fade();
        }
    }
    private IEnumerator WaitFrameThenUnfade()
    {
        yield return(0);

        // Start at the fade color, then unfade.
        fadeReference.Fade(fadeColor, 0f);
        fadeReference.Unfade(unfadeSpeed);
    }
Пример #3
0
    IEnumerator switchScene(string sceneName)
    {
        VRTK_HeadsetFade headsetFade = gameObject.GetComponentInChildren <VRTK_HeadsetFade>();

        headsetFade.Fade(Color.black, Constants.FadeSpeed);
        yield return(new WaitForSeconds(Constants.FadeSpeed));

        Debug.Log("Loading Scene " + sceneName + "...");
        yield return(SceneManager.LoadSceneAsync(sceneName));

        Debug.Log("Loading Scene Done" + "...");

        headsetFade.Unfade(Constants.FadeSpeed);
        yield return(new WaitForSeconds(Constants.FadeSpeed));
    }
Пример #4
0
    void Fade(bool fadeOut)
    {
        if (headsetFade == null || fadeColor.a == 0)
        {
            return;
        }

        if (fadeOut)
        {
            headsetFade.Fade(Color.black, gazeTriggerDuration);
        }
        else
        {
            headsetFade.Unfade(unfadeRate);
        }
    }
Пример #5
0
    private void Start()
    {
        VRTK_HeadsetFade fade = VRTKScripts.instance.GetComponentInChildren <VRTK_HeadsetFade>();

        if (fade != null)
        {
            fade.Fade(Color.black, 0);
        }

        Transform playArea = VRTK_DeviceFinder.PlayAreaTransform();

        playArea.position = this.transform.position;
        playArea.rotation = this.transform.rotation;

        OnStart();

        if (fade != null)
        {
            fade.Unfade(0.5f);
        }
    }
    void Update()
    {
        timer  += Time.deltaTime;
        timer2 += Time.deltaTime;

        if (controller == null)
        {
            Debug.Log("Controller not initialized");
            return;
        }

        var device = SteamVR_Controller.Input((int)trackedObj.index);

        if (activateFade)
        {
            if (!fade)
            {
                Invoke("StartFade", 0f);
                fade   = true;
                timer2 = 0f;
            }
            else if (timer2 >= 0.45f)
            {
                fade = false;
                CancelInvoke("StartFade");
                headsetFade.Unfade(0.05f);
                activateFade = false;
            }
        }

        if (controller.GetTouch(touchpad))
        {
            var touchPadVector = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);

            Quaternion orientation = rig.transform.rotation;

            if (rig != null && !faded)
            {
                //float dTurn;
                //dTurn = rig.rotation.y - previousTurn;
                //previousTurn = rig.rotation.y;
                //float angularSpeed = dTurn/Time.deltaTime;
                //float x = touchPadVector.x;
                //x = Mathf.Pow(x, 5);
                //if (x < -0.4 && !snap)
                //{
                //    rig.transform.Rotate(0, -22.5f, 0, Space.World);
                //    snap = true;
                //}
                //else if (x > 0.4 && !snap)
                //{
                //    rig.transform.Rotate(0, 22.5f, 0, Space.World);
                //    snap = true;
                //}
                //else
                //{
                //    rig.transform.Rotate(0, _mHorizontalTurnSpeed * Time.deltaTime * x * 10, 0, Space.World);
                //    snap = false;
                //}
                //if (snap && !fade)
                //{
                //    Invoke("StartFade", 0f);
                //    fade = true;
                //    timer2 = 0f;

                //}
                //else if (timer2 >= 0.4f && fade)
                //{
                //    fade = false;
                //    CancelInvoke("StartFade");
                //    headsetFade.Unfade(0.05f);
                //    faded = true;
                //}

                float rotateSpeed = Mathf.Sign(touchPadVector.x) * (10f / (1f - Mathf.Exp(3f * Mathf.Abs(touchPadVector.x) + Mathf.Log((10f / 22.5f) + 1f))) + 22.5f);
                rig.transform.Rotate(0, rotateSpeed * Time.deltaTime, 0, Space.World);
            }
        }

        if (controller.GetPressDown(touchpad))
        {
            var touchPadVector = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);
            activateFade = true;
            rig.transform.Rotate(0, 22.5f * Mathf.Sign(touchPadVector.x), 0, Space.World);
        }

        //if (controller.GetTouchUp(touchpad))
        //{
        //    faded = false;
        //    if (fade)
        //    {
        //        fade = false;
        //        CancelInvoke("StartFade");
        //        headsetFade.Unfade(0);
        //    }
        //}
    }
Пример #7
0
 private void UnScreenFlash()
 {
     headsetFade.Unfade(0.2f);
 }