为了账号安全,请及时绑定邮箱和手机立即绑定

写字符串 10 秒

写字符串 10 秒

C#
哈士奇WWW 2022-01-09 16:55:54
我正在尝试一种实现自写文本的方法,就像你通常在 2D 游戏中看到的那样,但我发现自己陷入了悬崖,换句话说,我想我被卡住了在这种特殊情况下,什么是不错的谷歌搜索?private IEnumerator Narrative(string line, float seconds){    transform.GetChild(narratorPanel).GetComponent<CanvasGroup>().alpha = 1f; /* Begin narrative */        for (int i = 0; i < 10000; i++)        {            while (seconds >= 0)            {                seconds -= Time.smoothDeltaTime;            // ( seconds / line.Length ) = distance between each character in a timeframe            // By the end the entire line must be displayed and chances are it's going to disappear immediately after the last character so I'll also have to implement some kind of padding so that the user is able to read it            yield return null;            }        }    transform.GetChild(narratorPanel).GetComponent<CanvasGroup>().alpha = 0f; /* End narrative */}
查看完整描述

1 回答

?
守候你守候我

TA贡献1802条经验 获得超10个赞

您以这种方式实施您的想法是否有原因?考虑以下方法,看看它是否符合您想要实现的目标。


IEnumerator WriteText(string Text,float interval)

{

    string dummyText = "";

    foreach(char s in Text)

    {

        dummyText += s;

        //write to the text object

        _TextObject.text = dummyText;

        yield return new WaitForSeconds(interval);


    }


查看完整回答
反对 回复 2022-01-09
  • 1 回答
  • 0 关注
  • 183 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号