Well… I want to have a dialogue system where I can have control over pretty much every sentence. So, I decided to do this script in which I can make new methods to tell each sentence what to do like I could put an animation at the end or start of the dialogue, I can put an effect or something. so I made it so that it takes a display of arrays and then loops through them and activating initialize sentence and then waiting until it ends with the bool result.
public TMP_Text TextBox;
public Canvas TextBackground;
SoftDiologueDisplay Container;
Queue<string> AllText;
SoftTextRunner Runner;
bool result;
private void Awake() {
AllText = new Queue<string>();
Container = FindObjectOfType<SoftDiologueDisplay>();
Runner = FindObjectOfType<SoftTextRunner>();
}
private void Update() {
if(result == true)
{
result = false;
}
print(result);
print(Container.Sentences.TimeBetweenText);
}
public void InitializeText(SoftDiologueDisplay Diologue)
{
AllText.Clear();
TextBackground.gameObject.SetActive(true);
foreach(string text in Diologue.Sentences.Text)
{
AllText.Enqueue(text);
}
StartCoroutine(NextSentence());
}
public IEnumerator NextSentence()
{
while(AllText.Count > 0)
{
string sentence = AllText.Dequeue();
TextBox.text = sentence;
yield return new WaitForSecondsRealtime(Container.Sentences.TimeBetweenText * Time.deltaTime * 100 );
}
End();
}
void End()
{
TextBackground.gameObject.SetActive(false);
result = true;
}
public IEnumerator AddingToSoftDiologueToStart(SoftDiologueDisplay[] SoftRunner)
{ print(SoftRunner.Length + " hi");
for(int a = 0 ; a < SoftRunner.Length; a++)
{
InitializeText(SoftRunner[a]);
yield return new WaitUntil(() => result == true);
print("Wellllllllll");
}
}
public void startingSentences(SoftDiologueDisplay[] diplay)
{
StartCoroutine(AddingToSoftDiologueToStart(diplay));
}
so my problem at the moment is that when it finishes up the first cycle… when the first item in the array of softdiologuedisplay in AddingtoSoftdiologuetostart, the rest of them start getting skipped over or go by pretty fast on nextsentence. If someone can help me with this code I’d greatly appreciate it. I’m a noob and I just start writing code as I go so if this is very choppy or it doesn’t make sense please give me some criticism and I’ll try to fix it. Also if you know a better way of doing a dialogue that has dialogue options, is very customizable, and is over all better than mine… pls tell me