Example #1
0
    // routine for the fade effect, pass in a target alpha value
    IEnumerator FadeRoutine(float alpha)
    {
        // pause for delay seconds
        yield return(new WaitForSeconds(delay));

        // cross fade the alpha value of the MaskableGraphic
        m_graphic.CrossFadeAlpha(alpha, timeToFade, true);
    }
Example #2
0
    IEnumerator FadeRoutine(float alpha)
    {
        yield return(new WaitForSeconds(delay));

        m_graphic.CrossFadeAlpha(alpha, timeToFade, true);
        yield return(new WaitForSeconds(delay));

        SceneManager.LoadScene("Main");
    }
Example #3
0
    // Start is called before the first frame update
    void Start()
    {
        MaskableGraphic g = (roundText == null) ? (MaskableGraphic)animImage : (MaskableGraphic)roundText;

        g.CrossFadeAlpha(0, 0, true);
        if (playOnStart)
        {
            StartCoroutine(RoundAnimation());
        }
    }
Example #4
0
    public IEnumerator RoundAnimation()
    {
        if (isRoundText)
        {
            roundText.text = "Round " + SessionManager.currentRound;
        }
        else if (roundText != null)
        {
            roundText.text = text;
        }

        MaskableGraphic g = (roundText == null) ? (MaskableGraphic)animImage: (MaskableGraphic)roundText;

        g.transform.localScale = new Vector3(largeSize, largeSize, largeSize);

        g.CrossFadeAlpha(1, fadeTime, false);
        float waitUntil = Time.time + fadeTime + holdTime;

        //Invoke("PlaySound", fadeTime - 0.15f);
        PlaySound();

        while (Time.time < waitUntil)
        {
            g.transform.localScale = Vector3.Lerp(g.transform.localScale, new Vector3(1, 1, 1), scaleLerpSpeed * Time.deltaTime);
            yield return(new WaitForEndOfFrame());
        }

        g.CrossFadeAlpha(0, fadeTime, false);
        waitUntil = Time.time + fadeTime;

        while (Time.time < waitUntil)
        {
            g.transform.localScale = Vector3.Lerp(g.transform.localScale, new Vector3(smallSize, smallSize, smallSize), scaleLerpSpeed * Time.deltaTime);
            yield return(new WaitForEndOfFrame());
        }
    }
Example #5
0
    IEnumerator FadeRoutine(float alpha, bool fadeChildren = true)
    {
        yield return(new WaitForSeconds(delay));

        m_graphic.CrossFadeAlpha(alpha, timeToFade, true);

        if (fadeChildren)
        {
            MaskableGraphic[] maskableGraphics = GetComponentsInChildren <MaskableGraphic>();
            foreach (MaskableGraphic graphic in maskableGraphics)
            {
                graphic.CrossFadeAlpha(alpha, timeToFade, true);
            }
        }
    }
Example #6
0
    private IEnumerator FadeRoutine(float alpha)
    {
        yield return(new WaitForSeconds(delay));

        maskableGraphic.CrossFadeAlpha(alpha, timeToFade, true);
    }
Example #7
0
    ///<summary>Fades MaskableFraphic to alpha</summary>
    IEnumerator FadeRoutine(float alpha)
    {
        yield return(new WaitForSeconds(_delay));

        _graphic.CrossFadeAlpha(alpha, _timeToFade, true);
    }
Example #8
0
 public void Fade()
 {
     backgroundImage.CrossFadeAlpha(0f, fadeTime * 1.2f, false);
     foregroundImage.CrossFadeAlpha(0f, fadeTime * 1.2f, false);
     faded = true;
 }
Example #9
0
 private void Fade(MaskableGraphic maskableGraphic, float targetAlpha, float duration)
 {
     maskableGraphic.CrossFadeAlpha(targetAlpha, duration, true);
 }
    IEnumerator FadeRoutine(float alpha)
    {
        yield return(new WaitForSeconds(delay));

        m_graphic.CrossFadeAlpha(alpha, timeToFade, true); // target alpha value, time to fade value, ignore time scale boolean value. True means it will fade even if game pause
    }
Example #11
0
    void UpdateFun()
    {
        float v = 0;

        if (curve == null)
        {
            v = time;
        }
        else
        {
            v = curve.Evaluate(time);
        }

        Vector3 value = param * v;


        switch (type)
        {
        case Type.pos:
        {
            transform.localPosition += value - oldCurverValue;
        }
        break;

        case Type.scale:
        {
            transform.localScale += value - oldCurverValue;
        }
        break;

        case Type.rotate:
        {
            transform.Rotate(value - oldCurverValue);
        }
        break;

        case Type.Color:
        {
            MaskableGraphic t = GetComponent <MaskableGraphic>();

            if (oldCurverValue == Vector3.zero)
            {
                oldCurverValue = new Vector3(t.color.r, t.color.g, t.color.b);
            }

            value   = value + oldCurverValue * (1 - v);
            t.color = new Color(value.x, value.y, value.z);

            value = oldCurverValue;
        }
        break;

        case Type.Color3D:
        {
            Renderer t = GetComponent <Renderer>();

            t.material.SetColor("_Color", new Color(value.x, value.y, value.z));
        }
        break;

        case Type.Alpha:
        {
            MaskableGraphic t = GetComponent <MaskableGraphic>();
            t.CrossFadeAlpha(v, 0, false);
        }
        break;

        case Type.Light:
        {
            if (m == null)
            {
                m = new Material(Shader.Find("aoe/ui_light"));

                Image t = GetComponent <Image>();
                t.material = m;
            }

            m.SetFloat("_Light", v);
        }
        break;

        case Type.AddColor:
        {
            if (m == null)
            {
                m = new Material(Shader.Find("aoe/ui_add"));


                MaskableGraphic t = GetComponent <MaskableGraphic>();
                if (t != null)
                {
                    t.material = m;
                    m.SetColor("_Color", new Color(value.x, value.y, value.z));
                }
            }

            m.SetFloat("_Light", v);
        }
        break;
        }
        oldCurverValue = value;
    }
Example #12
0
    // =============================================================================
    // =============================================================================
    //                          FADE IN / FADE OUT
    // =============================================================================
    // =============================================================================

    private void Fade(float targetAlpha, float duration)
    {
        blackScreenToFade.CrossFadeAlpha(targetAlpha, duration, true);
    }