zoukankan      html  css  js  c++  java
  • UGUI打字机效果文本组件

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    
    public class TypewriterText : MonoBehaviour {
    	private Text text;
    	private string content;
    	private float delay;
    	// Use this for initialization
    	void Start () {
    		text = gameObject.GetComponent<Text>();
    		if(text == null)
    		{
    			Debug.LogError("没添加Text脚本");
    		}
    	}
    	
    	public void TypeShow(string txt, float _delay=0.5f)
    	{
    		content = txt;
    		delay = _delay;
    		StartCoroutine(AppearText());
    	}
    	public void AllShow(string txt)
    	{
    		StopAllCoroutines();
    		text.text = txt;
    	}
    	private IEnumerator AppearText()
    	{
    		char[] arr = content.ToCharArray();
    		for(int i = 0; i<arr.Length; i++)
    		{
    			text.text += arr[i];
    			yield return new WaitForSeconds(delay);
    		}
    	}
    }
    

      

  • 相关阅读:
    day4
    day3
    day2
    day1
    spring-boot-note
    spring-boot-cli
    jquery ajax rest invoke
    spring-boot
    docker mysql
    jpa OneToMany
  • 原文地址:https://www.cnblogs.com/ssw-men/p/10560463.html
Copyright © 2011-2022 走看看