So i've got a problem with IEnumerators with the yield return Talking call at the end of the options function. The talking function is then later set to yield return true when the text file reaches a line that should end the option. But the options function doesn't continue from the yield return talking call at the end and just stops even though the talking function returns true.
Edits:
So the problem is the options function doesn't respond to the talking function being set to true in the yield statement at the end of the function.
I've used breakpoints to make sure options isn't called multiple times and that the talking function reaches the yield return true. Just the options function never continues from the yield statement.
Ive included both the functions below I can add the whole c# script and the text file if needs.
IEnumerator Talking(string[] text_file, int line)
{
while (line != text_file.Length)
{
if (text_file[line].Split(' ')[0] == "Keyword")
{
var key = text_file[line].Split(' ')[1];
switch (key)
{
case "Option":
yield return Option(text_file, line);
break;
case "End":
End();
yield break;
case "Code":
line++;
Code(text_file[line]);
break;
default:
print("Keyword " + key + " not reconsised");
break;
}
}
else if (text_file[line] == "End_Option")
{
line++;
yield return true;
}
output_Text.DisplayText(text_file[line]);
while (!controller.click)
{
yield return null;
}
line++;
}
}
IEnumerator Option(string[] text_file, int line)
{
yield return new WaitForEndOfFrame();
var options = 2;
int option_start = line;
int option_1 = 0;
int option_2 = 0;
line++;
var split = text_file[line].Split('|');
output_Text.Display_Options(split[0], split[1]);
while (!controller.click)
{
yield return null;
}
line++;
while (options != 0)
{
while (text_file[line] != "End_Option")
{
option_1++;
line++;
}
line++;
options--;
while (text_file[line] != "End_Option")
{
option_2++;
line++;
}
line++;
options--;
}
while (output_Text.choice == 0)
{
yield return null;
}
if (output_Text.choice == 1)
{
output_Text.choice = 0;
line = option_start + 1;
}
if (output_Text.choice == 2)
{
output_Text.choice = 0;
line = option_start + 2 + option_1;
}
yield return Talking(text_file, line);
line = option_start + 3 + option_1 + option_2;
yield return true;
}
}