Hello everyone, it’s my first time here, so if I’am posting that on the wrong place or something like that, please tell me.
I’am trying to put some interval between the dialogues that I will put on Editor, instead of press some key to advance the dialogue, I want to put like “10” seconds of duration for every string in dialogue.
So, it’s basically about dialogue script, that when the “Player” enter on a Trigger2D zone activate the following script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Active_Dialog : MonoBehaviour
{
public string[] dialogue;
public Text output;
private int curLine;
void Start()
{
output.enabled = false;
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.CompareTag("Player"))
{
output.enabled = true;
output.text = dialogue[0];
}
}
void OnGUI()
{
if (output.enabled == true)
{
curLine++;
if (curLine < dialogue.Length)
{
output.text = dialogue[curLine];
}
else
{
curLine = 0;
output.enabled = false;
}
}
}
I already tried somethings like put a Coroutine, I tried in many lines to put a Coroutine with differentes blocks of code, the max that I got was the first and the second string of the array stay the amount of time I wanted. But I still messy about how to use Coroutine (since everywhere say a different thing to another one) and I’am pretty sure that I dont got it the idea of “pause and execute the next line of the code in x amount of seconds” yet…
So if someone could explain how I can make that, I will be pretty thankful!