Печатающий текст при нажатии на кнопку

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

public class TextOne : MonoBehaviour
{
    public Text TextGameObject;
    private string text;

    private void Start()
    {
        text = TextGameObject.text;
        TextGameObject.text = "";
        StartCoroutine(TextCorutine());
    }


    IEnumerator TextCorutine()
    {
        foreach (char abc in text)
        {
            TextGameObject.text += abc;
            yield return new WaitForSeconds(0.05f);
        }
    }
}

Как сделать что бы в unity при нажатии печатался текст, а не тогда когда запускаешь unity


Ответы (1 шт):

Автор решения: 909 008
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TextOne : MonoBehaviour
{
    public Text TextGameObject;
    private string text;

    public void OneText()
    {
        text = TextGameObject.text;
        TextGameObject.text = "";
        StartCoroutine(TextCorutine());
    }


    IEnumerator TextCorutine()
    {
        foreach (char abc in text)
        {
            TextGameObject.text += abc;
            yield return new WaitForSeconds(0.05f);
        }
    }
}
→ Ссылка