Script/Transition/TransformExtention.cs
/// <summary>
/// Fades out a Ui Transform using CanvasGroup component
/// </summary>
/// <param name="transform">self transform to fade out</param>
/// <param name="duration">fading duration time in seconds</param>
/// <param name="easeType">fading easeType</param>
/// <param name="onCompleteCallback">callback on tween completion</param>
/// <param name="deactiveOnComplete">Whether deactive object when fade out completed?</param>
/// <param name="blockRaycast">block Raycasts during tween time?</param>
/// <returns>returns Tweener that can be used for other purposes.</returns>
Fades out a Ui Transform using CanvasGroup component
Fades out a Ui Transform using CanvasGroup component
public static Tweener FadeOut(this Transform transform,
            float duration,
            Ease easeType = Ease.Linear,
            Action onCompleteCallback = null,
            bool deactiveOnComplete = false,
            bool blockRaycast = false)
        {
            CanvasGroup image = InitCanvasGroup(transform, blockRaycast);
            image.alpha = 1;
            Tweener tween = image.DOFade(0f, duration);
            tween.SetEase(easeType);
            tween.OnComplete(() =>
            {
                if (onCompleteCallback != null)
                    onCompleteCallback.Invoke();
                image.blocksRaycasts = true;
                if (deactiveOnComplete)
                    transform.gameObject.SetActive(false);
            });
            return tween;
        }
public static Tweener FadeOut ( this Transform transform , float duration , Ease easeType = Ease . Linear , Action onCompleteCallback = null , bool deactiveOnComplete = false , bool blockRaycast = false ) { CanvasGroup image = InitCanvasGroup ( transform , blockRaycast ) ; image . alpha = 1 ; Tweener tween = image . DOFade ( 0f , duration ) ; tween . SetEase ( easeType ) ; tween . OnComplete ( ( ) => { if ( onCompleteCallback != null ) onCompleteCallback . Invoke ( ) ; image . blocksRaycasts = true ; if ( deactiveOnComplete ) transform . gameObject . SetActive ( false ) ; } ) ; return tween ; }
Fades out a Ui Transform using CanvasGroup component
Fades out a Ui Transform using CanvasGroup component
returns Tweener that can be used for other purposes.
returns Tweener that can be used for other purposes .
Transform
this
duration
float
fading duration time in seconds
fading duration time in seconds
easeType
Ease
None
onCompleteCallback
Action
callback on tween completion
callback on tween completion
deactiveOnComplete
bool
None
blockRaycast
bool
None
transform
self transform to fade out
self transform to fade out