Apologies for the very late reply!
The system is composed of "DialogueManager.cs" (handles typewriter effect, advancing lines, freezing player) and "DialogueData.cs" (ScriptableObject to store lines + portrait per conversation).
So it is done entirely in code, no animation needed. I believe it is called "typewriter effect". I use IEnumerator:
private IEnumerator TypeLine(DialogueData.DialogueLine line)
{
isTyping = true;
dialogueText.text = "";
foreach (char c in line.text)
{
dialogueText.text += c; // this will add one character at a time
yield return new WaitForSeconds(typeSpeed); // this will wait between each character
}
isTyping = false;
}It loops through every character in the string one by one, adds it to the text, then waits a tiny amount of time before the next one..
The press space to complete instantly part is just:
if (Input.GetKeyDown(advanceKey))
{
if (isTyping)
SkipTypewriter();
}
private void SkipTypewriter()
{
StopCoroutine(typeCoroutine);
dialogueText.text = currentDialogue.lines[currentLineIndex].text; // this will show the line all at once
isTyping = false;
}
Let me know if this helps :)