Написать строку в течение 10 секунд - PullRequest
0 голосов
/ 10 сентября 2018

Я пытаюсь придумать способ реализовать самописный текст, подобный тому, который вы обычно видите в 2D играх, но я оказался в некотором обрыве, в других слова, я думаю, я застрял

Каким будет хороший поиск в Google в данном конкретном случае?

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 Ответ

0 голосов
/ 10 сентября 2018

Есть ли причина, по которой вы воплощаете свою идею таким образом? Рассмотрите следующий метод и посмотрите, соответствует ли он тому, чего вы пытаетесь достичь.

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);

    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...