废话少说,上代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.UI;
public class s2errortext : MonoBehaviour
{
public Text text;
// Start is called before the first frame update
void Start()
{
text = this.GetComponent<Text>();
text.DOText("[NextworkError] Exception: Failed to fetch \n[NextworkError] Exception: Connecting to NetUpdate server ", 6);
}
// Update is called once per frame
void Update()
{
}
}
代码放在text项目上,“ \n”为换行符。效果如下:
屏幕录制-2020-02-08-下午2.43.gif
ps,这是基于没有任何触发条件的自动变化效果,,且代码必须放在text上。。
更个新,基于上述代码,简化操作,不设置public text,直接挂代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.UI;
public class middletext : MonoBehaviour
{
// Start is called before the first frame update
private void Start()
{
Text text = this.GetComponent<Text>();
text.DOText("findeit .. \nfind aaa ", 5).SetEase(Ease.Linear);//setease 匀速的意思
}
}
网友评论