您当前的位置: 首页 >  unity

云小川

暂无认证

  • 4浏览

    0关注

    78博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

unity C#字符串读取

云小川 发布时间:2021-10-22 11:41:24 ,浏览量:4

using UnityEngine; using System.Collections; using UnityEngine.UI;

public class MyTextChar : MonoBehaviour {

    private Text uiText;     //储存中间值     private string words;     //每个字符的显示速度     private float timer;     private float timer2;     //限制条件,是否可以进行文本的输出     private bool isPrint = false;     private float perCharSpeed = 1;

    private int text_length = 0;     private string Ctext;     // Use this for initialization     void Start()     {

        uiText = GetComponent();         words = GetComponent().text;         isPrint = true;     }

    // Update is called once per frame     void Update()     {

        printText();     }

    void printText()     {         try         {             if (isPrint)             {

                uiText.text = words.Substring(0, (int)(perCharSpeed * timer));//截取

                timer += Time.deltaTime;

            }         }         catch (System.Exception)         {             printEnd();         }     }

    void printEnd()     {         isPrint = false;     } }  

关注
打赏
1663746399
查看更多评论
立即登录/注册

微信扫码登录

0.0356s