Exemplo n.º 1
0
 // speed must be > 0
 public void FadeToColor(Color overlayColor, float speed)
 {
     m_FullScreenFadeAmount  = 0.0f;
     m_FullScreenTargetColor = overlayColor;
     m_FullScreenFadeSpeed   = speed;
     m_FullScreenFadeState   = FullScreenFadeState.FadingToColor;
 }
Exemplo n.º 2
0
 public void SetOverlayToBlack()
 {
     m_FullScreenOverlay.material.color = Color.black;
     m_FullScreenFadeAmount             = 1.0f;
     m_FullScreenFadeState       = FullScreenFadeState.Default;
     m_FullScreenOverlay.enabled = true;
 }
Exemplo n.º 3
0
 // speed must be > 0
 public void FadeToScene(float speed)
 {
     if (m_FullScreenFadeAmount > 0)
     {
         m_FullScreenFadeSpeed    = speed;
         m_FullScreenFadeState    = FullScreenFadeState.FadingToScene;
         m_FullScreenFadeEatFrame = true;
     }
 }
Exemplo n.º 4
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);
                }
            }
        }