Example #1
0
    void UpdateBackground(bool anyScreenVisible, bool force)
    {
        if (m_Background == null)
        {
            return;
        }

        bool  display   = m_BackgroundCustomVisibility && anyScreenVisible;
        float tweenFrom = m_Background.FadeAlpha;
        float tweenTo   = 0.0f;

        m_Tweener.StopTweens(false);

        if (display == true)
        {
            tweenTo = 1.0f;

            if (m_Background.Visible == false)
            {
                m_Background.ShowImmediate(true);
            }
        }
        else if (display == false)
        {
            tweenTo = 0.0f;

            if (force == true)
            {
                m_Background.ShowImmediate(false);
            }
        }

        if (force == true)
        {
            m_Background.SetFadeAlpha(tweenTo, true);
        }
        else
        {
            m_BackgroundAlpha = tweenFrom;
            m_Tweener.TweenTo(this,
                              "m_BackgroundAlpha",
                              tweenTo,
                              0.15f,
                              Tween.Easing.Linear.EaseNone,
                              (tween, finished) =>
            {
                m_Background.SetFadeAlpha(m_BackgroundAlpha, true);
                if (finished == true && m_Background.FadeAlpha == 0.0f)
                {
                    m_Background.ShowImmediate(false);
                }
            });
        }
    }