Unity
0 : Unity <= DOTween Fade Out & Fade In
RIsN
2020. 11. 23. 23:53
>Durationがよく作動しない感じがする?
>もっと確認が必要。
// :: Fade Out
public System.Action CallBack_FadeOut = null; // Callback delegate
public void FadeOut(Image image)
{
image.gameObject.SetActive(true); // :: Render TRUE
DOTween.ToAlpha(
() => image.color,
alpha => image.color = alpha,
0f, // :: Target Value
1f) // :: Duration
.SetEase(Ease.InQuad) // :: Set Animation Play Type
.onComplete = () => // :: On Complete
{
this.CallBack_FadeOut?.Invoke(); // :: Call Back when this Action isn't null
this.CallBack_FadeOut = null; // :: Reset Action
image.gameObject.SetActive(false); // :: Render FALSE
};
}
// :: Fade In
public System.Action CallBack_FadeIn = null; // Callback delegate
public void FadeIn(Image image)
{
image.gameObject.SetActive(true); // :: Render TRUE
DOTween.ToAlpha(
() => image.color,
alpha => image.color = alpha,
1f, // :: Target Value
1f) // :: Duration
.SetEase(Ease.InQuad) // :: Set Animation Play Type
.onComplete = () => // :: On Complete
{
this.CallBack_FadeIn?.Invoke(); // :: Call Back when this Action isn't null
this.CallBack_FadeIn = null; // :: Reset Action
image.gameObject.SetActive(true); // :: Render TRUE
};
}
