UGUI—动态省略号效果

作者:追风剑情 发布于:2020-11-12 11:02 分类:Unity3d

示例:动态省略号效果

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 在字符串后面追加动态省略号效果...
/// </summary>
public class WaitEllipsisEffect : MonoBehaviour
{
    public Text text;
    public string content;
    public float interval = 0.3f;

    private float lastTime = 0;
    private int i = 0;
    private string[] ellips = new string[] {"", ".", "..", "..."};
    
    private void Update()
    {
        if (Time.time - lastTime < interval)
            return;
        lastTime = Time.time;
        text.text = content + ellips[i];
        i = (i + 1) % ellips.Length;
    }
}

运行效果

3335.gif

标签: Unity3d

Powered by emlog  蜀ICP备18021003号   sitemap

川公网安备 51019002001593号