Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (state != EFaderstate.none)
        {
            currentTime += Time.deltaTime;

            Color color = objectToFade.GetComponent <Image>().color;
            if (state == EFaderstate.fadeIn)
            {
                color.a = easeInOutQuad(currentTime / fadeTime);
            }
            else if (state == EFaderstate.fadeOut)
            {
                color.a = 1 - easeInOutQuad(currentTime / fadeTime);
            }
            objectToFade.GetComponent <Image>().color = color;

            if (currentTime > fadeTime)
            {
                if (state == EFaderstate.fadeOut)
                {
                    objectToFade.SetActive(false);
                }

                state = EFaderstate.none;
            }
        }
    }
Ejemplo n.º 2
0
    public void StartFadeOut()
    {
        Color color = objectToFade.GetComponent <Image>().color;

        color.a = 1.0f;
        objectToFade.GetComponent <Image>().color = color;

        objectToFade.SetActive(true);
        currentTime = 0.0f;
        state       = EFaderstate.fadeOut;
    }