zoukankan      html  css  js  c++  java
  • 在对话系统中实现打字机效果

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

  • 相关阅读:
    Uboot USB模式(RK3288变砖头的解决办法)
    C++ 解析一
    C++基础
    shell脚本分析二
    ASCII
    POJ 1970 The Game (DFS)
    PoJ1979 Red and Black (DFS)
    UVA 572 Oil Deposits (DFS)
    打印日历
    求第N个素数
  • 原文地址:https://www.cnblogs.com/xingyunge/p/8302586.html
Copyright © 2011-2022 走看看