using DG.Tweening;
public bool isDoTweenEnd;
public void SetShowFont(Text text, string context, float timer, bool richText = true)
{
DoTweenAnimation doTween = text.transform.GetComponent<DoTweenAnimation>();
if(doTween == null)
{
text.gameObject.AddComponent<DoTweenAnimation>();
doTween = text.transform.GetComponent<DoTweenAnimation>();
}
doTween.easeType = Ease.Linear;
doTween.autoKill = false;
doTween.autoPlay = false;
doTween.animationType = DG.Tweening.Core.DoTweenAnimationType.Text;
doTween.isFrom = false;
text.text = "";
Tweener tweener;
if(isDoTweenEnd)
{
tweener = text.DOText(context, timer, richText);
tweener.OnComplete(IsDoTweenComplete);
tweener.OnPlay(DoTweenPlaying);
}else
{
text.DoComplete();
}
}
private void IsDoTweenComplete()
{
isDoTweenEnd = true;
}
private void IsDoTweenComplete()
{
isDoTweenEnd = false;
}
是通过Dotween插件实现的