Ejemplo n.º 1
0
    private void fade()
    {
        // GUI.color affects both background and text colors, so back it up
        Color origColor = GUI.color;

        // set the fade color
        fadeColor.a = alphaFadeValue;
        GUI.color   = fadeColor;
        GUI.DrawTexture(rectTex, tex, ScaleMode.StretchToFill, true);
        // restore GUI color
        GUI.color = origColor;

        if (fadeDir.Equals(EnumFadeDirection.FADE_IN))
        {
            alphaFadeValue = Mathf.Clamp01(alphaFadeValue + (Time.deltaTime * fadeTimeFactor));
            if (alphaFadeValue == 1f)
            {
                finishedTransition = true;
            }
        }
        else if (fadeDir.Equals(EnumFadeDirection.FADE_OUT))
        {
            alphaFadeValue = Mathf.Clamp01(alphaFadeValue - (Time.deltaTime * fadeTimeFactor));
            if (alphaFadeValue == 0f)
            {
                finishedTransition = true;
                if (fadeOutOnStart)
                {
                    stopFading();                     // leaves state properly
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void fade()
    {
        // set the alpha color
        fadeColor.a = alphaFadeValue;
        fadeMat.SetColor("_Color", fadeColor);

        if (fadeDir.Equals(EnumFadeDirection.FADE_IN))
        {
            alphaFadeValue = Mathf.Clamp01(alphaFadeValue + (Time.deltaTime * fadeTimeFactor));
            if (alphaFadeValue == 1f)
            {
                finishedTransition = true;
            }
        }
        else if (fadeDir.Equals(EnumFadeDirection.FADE_OUT))
        {
            alphaFadeValue = Mathf.Clamp01(alphaFadeValue - (Time.deltaTime * fadeTimeFactor));
            if (alphaFadeValue == 0f)
            {
                finishedTransition = true;
                if (fadeOutOnStart)
                {
                    stopFading();                     // leaves state properly
                }
            }
        }
    }
Ejemplo n.º 3
0
 public void startFading(EnumFadeDirection direction)
 {
     this.enabled = true;
     // keeps the fade direction for the fade transition
     fadeDir = direction;
     // reset status
     finishedTransition = false;
     // sets starting alpha values depending on the fade direction
     if (direction.Equals(EnumFadeDirection.FADE_IN))
     {
         alphaFadeValue = 0f;
     }
     else if (direction.Equals(EnumFadeDirection.FADE_OUT))
     {
         alphaFadeValue = 1f;
     }
 }