Trying to wait 1 sec before updating the Text to the next line.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SubtitleRenderer : MonoBehaviour
{
public SubtitleHandler subtitleHandler; //scriptable object which contain an array of strings
public Text renderer;
int number;
// Start is called before the first frame update
void Start()
{
renderer.text = "";
number = 0;
gameObject.GetComponent<Collider>().enabled = true; //set the trigger
Debug.Log(subtitleHandler.Text.Length);
}
// Update is called once per frame
void OnTriggerEnter()
{
renderer.text = subtitleHandler.Text[number];
for (int i = 0; i < subtitleHandler.Text.Length; i++)
{
StartCoroutine(Example());
}
}
IEnumerator Example()
{
yield return new WaitForSecondsRealtime(1);
renderer.text = subtitleHandler.Text[number];
number = number + 1;
}
}