35 lines
742 B
C#
35 lines
742 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using TMPro;
|
|
|
|
public class Log : MonoBehaviour
|
|
{
|
|
TextMeshProUGUI tmpText;
|
|
void Awake()
|
|
{
|
|
tmpText = GetComponent<TextMeshProUGUI>();
|
|
}
|
|
void Start()
|
|
{
|
|
tmpText.text = "";
|
|
tmpText.enabled = false;
|
|
}
|
|
public void WriteOutLog(string text, float letterDelay = 0.05f)
|
|
{
|
|
StartCoroutine(WriteLog(text, letterDelay));
|
|
}
|
|
|
|
IEnumerator WriteLog(string text, float letterDelay)
|
|
{
|
|
tmpText.text = "";
|
|
tmpText.enabled = true;
|
|
|
|
foreach (char letter in text)
|
|
{
|
|
tmpText.text += letter;
|
|
yield return new WaitForSeconds(letterDelay);
|
|
}
|
|
tmpText.enabled = false;
|
|
}
|
|
}
|