/// <summary>
        /// Fades a <see cref="Canvas"/> asynchronously.
        /// </summary>
        /// <param name="from">The start value of the <see cref="Canvas"/>'s alpha.</param>
        /// <param name="to">The end value of the <see cref="Canvas"/>'s alpha.</param>
        /// <param name="duration">The duration of the fade, in seconds.</param>
        /// <returns>The awaitable task.</returns>
        private async UniTask FadeAsync(float from, float to, float duration)
        {
            await UniTaskExtensions.ProgressAsync(SetAlpha, from, to, duration, _cancellationTokenSource.Token);

            void SetAlpha(float alpha) => _canvasGroup.alpha = alpha;
        }
Beispiel #2
0
 /// <summary>
 /// Fades the announcement board in asynchronously.
 /// </summary>
 /// <param name="duration">The duration of the fade, in seconds.</param>
 /// <param name="token">The token for operation cancellation.</param>
 /// <returns>The awaitable task.</returns>
 private async UniTask FadeInAsync(float duration, CancellationToken token)
 {
     await UniTaskExtensions.ProgressAsync(SetAlpha, 0f, 1f, duration, token);
 }