实现文字首行缩进加打字机效果

实现文字首行缩进加打字机效果_第1张图片

将以下脚本挂在text上

using UnityEngine.UI;
using UnityEngine;

[RequireComponent(typeof(Text))]
public class NonBreakingSpaceTextComponent : MonoBehaviour
{
    public static readonly string no_breaking_space = "\u00A0";

    protected Text text;
    // Use this for initialization
    void Awake()
    {
        text = this.GetComponent();
        text.RegisterDirtyVerticesCallback(OnTextChange);
    }

    public void OnTextChange()
    {
        if (text.text.Contains(" "))
        {
            text.text = text.text.Replace(" ", no_breaking_space);
        }
    }

}

 

然后利用dotween “     213124566”就可以了!

你可能感兴趣的:(小技巧)