Esempio n. 1
0
    /// <summary>
    /// Fade with complete control over all features. To instantly jump to the startAlpha value before any delay begins, set jumpToStartAlpha to true - this is useful for a delayed scene fade in from black.
    /// </summary>
    /// <param name='color'>
    /// Color.
    /// </param>
    /// <param name='startAlpha'>
    /// Start alpha.
    /// </param>
    /// <param name='endAlpha'>
    /// End alpha.
    /// </param>
    /// <param name='duration'>
    /// Duration.
    /// </param>
    /// <param name='delay'>
    /// Delay.
    /// </param>
    /// <param name='jumpToStartAlpha'>
    /// Jump to start alpha.
    /// </param>
    public static void Fade(Color color, float startAlpha, float endAlpha, float duration, float delay, bool jumpToStartAlpha, System.Action onComplete = null)
    {
        CheckInstance();
        ChangeColor(color, false);

        startColor   = baseColor;
        startColor.a = startAlpha;

        endColor   = baseColor;
        endColor.a = endAlpha;

        if (jumpToStartAlpha)
        {
            currentColor.a = startAlpha;
        }

        _instance.StopAllCoroutines();
        _instance.StartCoroutine(_instance.DoFade(duration, delay, onComplete));
    }