Ejemplo n.º 1
0
    IEnumerator Fade()
    {
        float elapsedTime = 0f;
        float duration    = 0.5f;

        while (elapsedTime < duration)
        {
            splatterRenderer.transform.localScale = Vector3.one * RSLerp.EaseOutCubic(3f, 0.001f, elapsedTime, duration);
            yield return(new WaitForEndOfFrame());

            elapsedTime = Mathf.Min(duration, elapsedTime + Time.deltaTime);
        }

        yield return(new WaitForSeconds(4.5f));

        Remove();
    }
Ejemplo n.º 2
0
    IEnumerator Fade()
    {
        float elapsedTime = 0f;

        Vector3 startPos = transform.position;

        if (trn != null)
        {
            startPos = trn.position;
            //    size = trn.localScale.x*0.5f;
        }

        Vector3 endPos = startPos + Vector3.down * size * 0.5f;

        if (normal.y != 0)
        {
            endPos = startPos;
        }
        while (elapsedTime < duration)
        {
            color.a = RSLerp.EaseInOutCubic(1, 0, elapsedTime, duration);
            Color emissionColor = RSLerp.EaseInOutCubic(color * 0.25f, Color.black, elapsedTime, duration);
            if (trn != null)
            {
                trn.position   = RSLerp.EaseOutCubic(startPos, endPos, elapsedTime, duration);
                trn.localScale = Vector3.one * RSLerp.EaseOutCubic(0.75f, 1.25f, elapsedTime, duration);
                renderer2.material.SetColor("_Color", color);
                renderer2.material.SetColor("_EmissionColor", emissionColor);
            }

            renderer1.material.SetColor("_Color", color);
            renderer1.material.SetColor("_EmissionColor", emissionColor);
            yield return(new WaitForEndOfFrame());

            elapsedTime = Mathf.Min(duration, elapsedTime + Time.deltaTime);
        }

        Remove();
    }