SpringDragon

导航

 
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插件实现的

posted on 2018-01-17 14:11  chenquanlong  阅读(357)  评论(0编辑  收藏  举报