im making subtitles for my game and i have already written code for it show the letters 1 by 1 but the problem is that it writes the entire text file and i want to only write a specific line from it.
here is my code so far:
using UnityEngine;
using TMPro;
using System;
public class SubtitleController : MonoBehaviour
{
private TextMeshProUGUI Subtitle;
public float speed = 0.5f;
public TextAsset SubtitleFile;
// Start is called before the first frame update
void Start()
{
Subtitle = GetComponent<TextMeshProUGUI>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.O))
{
StartCoroutine("Subtitle1");
}
}
IEnumerator Subtitle1()
{
foreach (Char sub in SubtitleFile.ToString())
{
Subtitle.text += sub;
yield return new WaitForSeconds(speed);
}
}
}