Exemplo n.º 1
0
 public void FadeOut(OnFadeComplete onFadeCompleteHandler)
 {
     fadeImage.enabled          = true;
     fadeImage.fillClockwise    = false;
     currentFillAmount          = 1f;
     fadeImage.fillAmount       = 0f;
     isAnimating                = true;
     this.onFadeCompleteHandler = onFadeCompleteHandler;
 }
Exemplo n.º 2
0
    public IEnumerator FadeOut()
    {
        isFading = true;
        //set oppacity to one to initialise fade in
        float oppacity = 1f;


        //start fading in tutorial prompts
        while (oppacity > 0f)
        {
            //Simultaneously fade in image elements
            oppacity -= 1f / 100f;

            foreach (Image image in images)
            {
                if (oppacity <= image.color.a)//Only decrease alpha of image
                {
                    image.color = new Color(image.color.r, image.color.g, image.color.b, oppacity);
                }
            }
            foreach (TextMeshProUGUI txt in texts)
            {
                if (oppacity <= txt.color.a)//Only decrease alpha of image
                {
                    txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, oppacity);
                }
            }

            //ensure background oppacity does not exceed given max
            if (oppacity <= maxLimitedOppacity)
            {
                foreach (Image limited in limitedImages)
                {
                    limited.color = new Color(limited.color.r, limited.color.g, limited.color.b, oppacity);
                }
            }

            yield return(new WaitForSeconds(fadeOutRate));
        }

        //at the end reset each value
        foreach (Image image in images)
        {
            image.color = new Color(image.color.r, image.color.g, image.color.b, 0f);
        }
        foreach (Image limited in limitedImages)
        {
            limited.color = new Color(limited.color.r, limited.color.g, limited.color.b, 0f);
        }
        foreach (TextMeshProUGUI txt in texts)
        {
            txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, 0f);
        }
        //call complete
        isFading = false;
        OnFadeComplete?.Invoke(gameObject);
    }
Exemplo n.º 3
0
    public static void AttachFaderTo(
        GameObject gameObject,
        Color fadeColor,
        eFadeType fadeType,
        float duration,
        OnFadeComplete callback)
    {
        Fader fader = gameObject.AddComponent <Fader>();

        fader.m_duration        = duration;
        fader.m_fadeColor       = fadeColor;
        fader.m_fadeType        = fadeType;
        fader.m_completeHandler = callback;
    }
Exemplo n.º 4
0
    public static void AttachFaderTo(
        GameObject gameObject,
        Color fadeColor,
        eFadeType fadeType,
        float duration, 
        OnFadeComplete callback)
    {
        Fader fader= gameObject.AddComponent<Fader>();

        fader.m_duration = duration;
        fader.m_fadeColor = fadeColor;
        fader.m_fadeType = fadeType;
        fader.m_completeHandler = callback;
    }
Exemplo n.º 5
0
    public void FadeTo(float volume, float duration, OnFadeComplete completeCallback)
    {
        if (fadeState == FadeState.Fading) {
            if (completionCallback != null) {
                completionCallback(false);
            }
        }

        if (audioSource == null)
            return;

        targetVolume = volume;
        startTime = Time.time;
        startVolume = audioSource.volume;
        completionCallback = completeCallback;
        fadeState = FadeState.Fading;
        fadeDuration = duration;
    }
Exemplo n.º 6
0
    private IEnumerator FadeIn()
    {
        float oppacity = 0;

        cam.SetActive(true);
        loadingScreen.SetActive(true);
        loadingText.SetActive(false);
        screenImage.color = new Color(screenImage.color.r, screenImage.color.g, screenImage.color.b, 0f);


        while (oppacity < 1f)
        {
            oppacity         += 0.01f;
            screenImage.color = new Color(screenImage.color.r, screenImage.color.g, screenImage.color.b, oppacity);
            yield return(new WaitForSeconds(fadeRate));
        }
        loadingText.SetActive(true);
        OnFadeComplete?.Invoke();
    }
Exemplo n.º 7
0
    private IEnumerator FadeIn()
    {
        isFading = true;
        //set oppacity to zero to initialise fade in
        float oppacity = 0f;

        foreach (Image image in images)
        {
            image.color = new Color(image.color.r, image.color.g, image.color.b, oppacity);
        }
        foreach (Image limited in limitedImages)
        {
            limited.color = new Color(limited.color.r, limited.color.g, limited.color.b, oppacity);
        }
        foreach (TextMeshProUGUI txt in texts)
        {
            txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, oppacity);
        }

        //start fading in elements
        while (oppacity < 1f)
        {
            oppacity += 1f / 100f;
            foreach (Image image in images)
            {
                image.color = new Color(image.color.r, image.color.g, image.color.b, oppacity);
            }
            foreach (TextMeshProUGUI txt in texts)
            {
                txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, oppacity);
            }

            //ensure background oppacity does not exceed given max
            if (oppacity <= maxLimitedOppacity)
            {
                foreach (Image limited in limitedImages)
                {
                    limited.color = new Color(limited.color.r, limited.color.g, limited.color.b, oppacity);
                }
            }

            yield return(new WaitForSeconds(fadeInRate));
        }

        //at the end reset each value
        foreach (Image image in images)
        {
            image.color = new Color(image.color.r, image.color.g, image.color.b, 1f);
        }
        foreach (Image limited in limitedImages)
        {
            limited.color = new Color(limited.color.r, limited.color.g, limited.color.b, maxLimitedOppacity);
        }
        foreach (TextMeshProUGUI txt in texts)
        {
            txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, 1f);
        }

        //call complete
        isFading = false;
        OnFadeComplete?.Invoke(gameObject);
    }