예제 #1
0
        public void FadeGroundPlaneIn(Color groundPlaneColor, float speed)
        {
            // The chaperone can also be forced on by uncommenting out the following 4 lines:
            //var chaperone = OpenVR.Chaperone;
            //if (chaperone != null ) {
            //  chaperone.ForceBoundsVisible(true);
            //}

            // Also, I tried to get the bounds color with the following, but it always returned white with
            // alpha of 0.2:
            //var chaperone = OpenVR.Chaperone;
            //if (chaperone != null) {
            //  HmdColor_t[] pOutputColorArray = new HmdColor_t[1];
            //  HmdColor_t[] pOutputCameraColor = new HmdColor_t[1];
            //  chaperone.GetBoundsColor(ref pOutputColorArray[0], 1, 0, ref pOutputCameraColor[0]);
            //  m_GroundPlaneTargetColor = new Color(pOutputColorArray[0].r,
            //                                       pOutputColorArray[0].g,
            //                                       pOutputColorArray[0].b,
            //                                       pOutputColorArray[0].a);
            //}

            m_GroundPlaneTargetColor = groundPlaneColor;
            m_GroundPlaneFadeSpeed   = speed;
            m_GroundPlaneFadeState   = GroundPlaneFadeState.FadingIn;
        }
예제 #2
0
 public void FadeGroundPlaneOut(float speed)
 {
     // The chaperone can also be forced off by uncommenting out the following 4 lines:
     //var chaperone = OpenVR.Chaperone;
     //if (chaperone != null ) {
     //  chaperone.ForceBoundsVisible(false);
     //}
     m_GroundPlaneFadeSpeed = speed;
     m_GroundPlaneFadeState = GroundPlaneFadeState.FadingOut;
 }
예제 #3
0
        void Update()
        {
            // Update the full screen overlay.
            if (m_FullScreenFadeState != FullScreenFadeState.Default)
            {
                Color overlayColor = m_FullScreenTargetColor;
                if (m_FullScreenFadeState == FullScreenFadeState.FadingToColor)
                {
                    m_FullScreenFadeAmount += m_FullScreenFadeSpeed * Time.deltaTime;
                    if (m_FullScreenFadeAmount >= 1.0f)
                    {
                        m_FullScreenFadeAmount = 1.0f;
                        m_FullScreenFadeState  = FullScreenFadeState.Default;
                    }
                }
                else if (m_FullScreenFadeState == FullScreenFadeState.FadingToScene)
                {
                    if (m_FullScreenFadeEatFrame)
                    {
                        m_FullScreenFadeEatFrame = false;
                    }
                    else
                    {
                        m_FullScreenFadeAmount -= m_FullScreenFadeSpeed * Time.deltaTime;
                    }
                    if (m_FullScreenFadeAmount <= 0.0f)
                    {
                        m_FullScreenFadeAmount = 0.0f;
                        m_FullScreenFadeState  = FullScreenFadeState.Default;
                    }
                }
                if (m_FullScreenFadeAmount > 0.0f)
                {
                    overlayColor.a = m_FullScreenFadeAmount;
                    m_FullScreenOverlay.material.color = overlayColor;
                    m_FullScreenOverlay.enabled        = true;
                }
                else
                {
                    m_FullScreenOverlay.enabled = false;
                }
            }

            // Update the ground plane grid overlay.
            if (m_GroundPlaneFadeState != GroundPlaneFadeState.Default)
            {
                Color overlayColor = m_GroundPlaneTargetColor;
                if (m_GroundPlaneFadeState == GroundPlaneFadeState.FadingIn)
                {
                    m_GroundPlaneFadeAmount += m_GroundPlaneFadeSpeed * Time.deltaTime;
                    if (m_GroundPlaneFadeAmount >= 1.0f)
                    {
                        m_GroundPlaneFadeAmount = 1.0f;
                        m_GroundPlaneFadeState  = GroundPlaneFadeState.Default;
                    }
                }
                else if (m_GroundPlaneFadeState == GroundPlaneFadeState.FadingOut)
                {
                    m_GroundPlaneFadeAmount -= m_GroundPlaneFadeSpeed * Time.deltaTime;
                    if (m_GroundPlaneFadeAmount <= 0.0f)
                    {
                        m_GroundPlaneFadeAmount = 0.0f;
                        m_GroundPlaneFadeState  = GroundPlaneFadeState.Default;
                    }
                }
                if (m_GroundPlaneFadeAmount > 0.0f)
                {
                    overlayColor.a *= m_GroundPlaneFadeAmount;
                    m_GroundPlaneOverlay.GetComponentInChildren <Renderer>().material.color = overlayColor;
                    m_GroundPlaneOverlay.SetActive(true);
                }
                else
                {
                    m_GroundPlaneOverlay.SetActive(false);
                }
            }
        }