首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >写入字符串10秒

写入字符串10秒
EN

Stack Overflow用户
提问于 2018-09-10 13:20:14
回答 1查看 97关注 0票数 0

我试图想出一种实现自写文本的方法,就像你通常在2D游戏中看到的那样,但我发现自己陷入了一个有点悬崖的境地,换句话说,我想我被困住了

在这种特殊的情况下,什么是一个好的谷歌搜索?

代码语言:javascript
运行
复制
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 */
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-10 16:07:50

你以这种方式实现你的想法有什么原因吗?考虑下面的方法,看看它是否适合你想要实现的目标。

代码语言:javascript
运行
复制
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);

    }
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52251521

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档