My script won't work as expected, it also crashes the unity editor [duplicate]
This question already has an answer here:
Unity - IEnumerator's yield return null
2 answers
I've been working on this project for some days now and I've encountered a bug that seems impossible to solve because not only no error messages appear but it also 'skips' my debug messages and crashes the editor itself.
The following script is a dialog displayer, it's apparently what's causing the issue (forgive the messed code, i messed it around while trying to solve the problem):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class DialogDisplayer : MonoBehaviour
{
[SerializeField] Dialog dialogFiles;
TextMeshPro outputTxt;
bool next, finished;
char comma = (char)44;
char period = (char)46;
// Use this for initialization
void Start()
{
outputTxt = GetComponent<TextMeshPro>();
StartCoroutine(type());
}
IEnumerator type()
{
int dialogIndex = 0;
do
{
foreach (char c in dialogFiles[dialogIndex].dialogText)
{
if (Input.GetKeyDown(KeyCode.Z))
{
outputTxt.text = dialogFiles[dialogIndex].dialogText;
Debug.Log("z pressed in the foreach");
break;
}
outputTxt.text += c;
if (c == ' ')
continue;
if (dialogFiles[dialogIndex].delayforPunctuations)
{
if (c == comma)
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters + 0.1f);
else if (c == period)
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters + 0.2f);
else
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters);
}
else
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters);
}
Debug.Log("Either finished or broken out of the loop");
while (!finished)
{
Debug.LogWarning("Entering while loop");
if (Input.GetKeyDown(KeyCode.Z))
{
Debug.Log("entered if");
finished = true;
dialogIndex++;
}
Debug.Log("got out");
}
} while (dialogIndex != dialogFiles.Length - 1);
}
}
c# unity3d
marked as duplicate by Community♦ Nov 15 '18 at 16:49
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Unity - IEnumerator's yield return null
2 answers
I've been working on this project for some days now and I've encountered a bug that seems impossible to solve because not only no error messages appear but it also 'skips' my debug messages and crashes the editor itself.
The following script is a dialog displayer, it's apparently what's causing the issue (forgive the messed code, i messed it around while trying to solve the problem):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class DialogDisplayer : MonoBehaviour
{
[SerializeField] Dialog dialogFiles;
TextMeshPro outputTxt;
bool next, finished;
char comma = (char)44;
char period = (char)46;
// Use this for initialization
void Start()
{
outputTxt = GetComponent<TextMeshPro>();
StartCoroutine(type());
}
IEnumerator type()
{
int dialogIndex = 0;
do
{
foreach (char c in dialogFiles[dialogIndex].dialogText)
{
if (Input.GetKeyDown(KeyCode.Z))
{
outputTxt.text = dialogFiles[dialogIndex].dialogText;
Debug.Log("z pressed in the foreach");
break;
}
outputTxt.text += c;
if (c == ' ')
continue;
if (dialogFiles[dialogIndex].delayforPunctuations)
{
if (c == comma)
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters + 0.1f);
else if (c == period)
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters + 0.2f);
else
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters);
}
else
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters);
}
Debug.Log("Either finished or broken out of the loop");
while (!finished)
{
Debug.LogWarning("Entering while loop");
if (Input.GetKeyDown(KeyCode.Z))
{
Debug.Log("entered if");
finished = true;
dialogIndex++;
}
Debug.Log("got out");
}
} while (dialogIndex != dialogFiles.Length - 1);
}
}
c# unity3d
marked as duplicate by Community♦ Nov 15 '18 at 16:49
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I'm not a Unity expert but I don't think you want to calltype()(great name for a method btw) when you start the coroutine. I think you pass it the method info:StartCoroutine(type);
– Crowcoder
Nov 15 '18 at 13:52
add a comment |
This question already has an answer here:
Unity - IEnumerator's yield return null
2 answers
I've been working on this project for some days now and I've encountered a bug that seems impossible to solve because not only no error messages appear but it also 'skips' my debug messages and crashes the editor itself.
The following script is a dialog displayer, it's apparently what's causing the issue (forgive the messed code, i messed it around while trying to solve the problem):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class DialogDisplayer : MonoBehaviour
{
[SerializeField] Dialog dialogFiles;
TextMeshPro outputTxt;
bool next, finished;
char comma = (char)44;
char period = (char)46;
// Use this for initialization
void Start()
{
outputTxt = GetComponent<TextMeshPro>();
StartCoroutine(type());
}
IEnumerator type()
{
int dialogIndex = 0;
do
{
foreach (char c in dialogFiles[dialogIndex].dialogText)
{
if (Input.GetKeyDown(KeyCode.Z))
{
outputTxt.text = dialogFiles[dialogIndex].dialogText;
Debug.Log("z pressed in the foreach");
break;
}
outputTxt.text += c;
if (c == ' ')
continue;
if (dialogFiles[dialogIndex].delayforPunctuations)
{
if (c == comma)
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters + 0.1f);
else if (c == period)
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters + 0.2f);
else
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters);
}
else
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters);
}
Debug.Log("Either finished or broken out of the loop");
while (!finished)
{
Debug.LogWarning("Entering while loop");
if (Input.GetKeyDown(KeyCode.Z))
{
Debug.Log("entered if");
finished = true;
dialogIndex++;
}
Debug.Log("got out");
}
} while (dialogIndex != dialogFiles.Length - 1);
}
}
c# unity3d
This question already has an answer here:
Unity - IEnumerator's yield return null
2 answers
I've been working on this project for some days now and I've encountered a bug that seems impossible to solve because not only no error messages appear but it also 'skips' my debug messages and crashes the editor itself.
The following script is a dialog displayer, it's apparently what's causing the issue (forgive the messed code, i messed it around while trying to solve the problem):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class DialogDisplayer : MonoBehaviour
{
[SerializeField] Dialog dialogFiles;
TextMeshPro outputTxt;
bool next, finished;
char comma = (char)44;
char period = (char)46;
// Use this for initialization
void Start()
{
outputTxt = GetComponent<TextMeshPro>();
StartCoroutine(type());
}
IEnumerator type()
{
int dialogIndex = 0;
do
{
foreach (char c in dialogFiles[dialogIndex].dialogText)
{
if (Input.GetKeyDown(KeyCode.Z))
{
outputTxt.text = dialogFiles[dialogIndex].dialogText;
Debug.Log("z pressed in the foreach");
break;
}
outputTxt.text += c;
if (c == ' ')
continue;
if (dialogFiles[dialogIndex].delayforPunctuations)
{
if (c == comma)
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters + 0.1f);
else if (c == period)
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters + 0.2f);
else
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters);
}
else
yield return new WaitForSeconds(dialogFiles[dialogIndex].delayBetweenLetters);
}
Debug.Log("Either finished or broken out of the loop");
while (!finished)
{
Debug.LogWarning("Entering while loop");
if (Input.GetKeyDown(KeyCode.Z))
{
Debug.Log("entered if");
finished = true;
dialogIndex++;
}
Debug.Log("got out");
}
} while (dialogIndex != dialogFiles.Length - 1);
}
}
This question already has an answer here:
Unity - IEnumerator's yield return null
2 answers
c# unity3d
c# unity3d
edited Nov 15 '18 at 15:12
Thomas Hilbert
2,8732727
2,8732727
asked Nov 15 '18 at 13:36
Everton ColomboEverton Colombo
33
33
marked as duplicate by Community♦ Nov 15 '18 at 16:49
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Community♦ Nov 15 '18 at 16:49
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I'm not a Unity expert but I don't think you want to calltype()(great name for a method btw) when you start the coroutine. I think you pass it the method info:StartCoroutine(type);
– Crowcoder
Nov 15 '18 at 13:52
add a comment |
I'm not a Unity expert but I don't think you want to calltype()(great name for a method btw) when you start the coroutine. I think you pass it the method info:StartCoroutine(type);
– Crowcoder
Nov 15 '18 at 13:52
I'm not a Unity expert but I don't think you want to call
type() (great name for a method btw) when you start the coroutine. I think you pass it the method info: StartCoroutine(type);– Crowcoder
Nov 15 '18 at 13:52
I'm not a Unity expert but I don't think you want to call
type() (great name for a method btw) when you start the coroutine. I think you pass it the method info: StartCoroutine(type);– Crowcoder
Nov 15 '18 at 13:52
add a comment |
2 Answers
2
active
oldest
votes
You do not use yield return anywhere in your Coroutine. This will cause your coroutine to run all iterations in the same frame.
From the Scripting documentation:
// every 2 seconds perform the print()
private IEnumerator WaitAndPrint(float waitTime)
{
while (true)
{
yield return new WaitForSeconds(waitTime);
print("WaitAndPrint " + Time.time);
}
}
Or you can use yield return null to pass the coroutine onto the next frame:
private IEnumerator YourDialogCoroutine()
{
bool finished = false;
while (!finished)
{
If(Input.GetKeyDown("Z"))
{
Debug.Log("Ending loop!");
finished = true;
}
yield return null;
}
}
Sorry, I didn't quite get that. Could you be more specific?
– Everton Colombo
Nov 15 '18 at 15:11
In the documentation for Coroutines, you have to use the statementyield returnand eithernullor something likeWaitForSeconds(float seconds). I would review the documentation in this case since you are missing this statement
– Eliasar
Nov 15 '18 at 15:13
Actually there are severalyield returns...
– Thomas Hilbert
Nov 15 '18 at 15:14
Coroutines will process all the information within a single frame (stackoverflow.com/a/32469037/1299146). Once your code falls through your foreach loop, there is noyield return nullat the end of your do-while.
– Eliasar
Nov 15 '18 at 15:22
so, i'd have to add a yield return null at the end of the do while?
– Everton Colombo
Nov 15 '18 at 15:24
|
show 6 more comments
From what I see....
In English: As soon as dialogIndex is not equal to dialogFiles.length minus one your script crashes.
Once this:
while (dialogIndex != dialogFiles.Length - 1);
is true, it enters into a endless loop. There are no directions of what to do once dialogFiles.Length -1 no longer is equal to dialogIndex.
Not sure what you are trying to accomplish with the final line of code there, but neither is the computer and it just waits for instructions once those conditions are met....forever.
It needs to be
while (dialogIndex != dialogFiles.Length - 1); {
Do Something;
provide Action To Eventually escape this loop (make dialogIndex = dialogFiles.Length - 1)
}
As for as the comment goes, you can do StartCoroutine(type()); or StartCoroutine("type"); That's fine.
that last line of code (while(dialogIndex != dialogFiles.Lenght - 1)) is actually part of a do while loop. And, while waiting for an answer, i've also found out that the line of code causing the problem is actually the while(!finished) loop, I still don't know why though.
– Everton Colombo
Nov 15 '18 at 14:25
just to make it clear, the goal of this script is to type out dialogFiles[dialogIndex].dialogText whit a type writer effect while also having the possibility to speed up the typing process by pressing 'z' on the keyboard and, once all the text was typed out, pressing 'z' again would lead to increasing dialogIndex by one.
– Everton Colombo
Nov 15 '18 at 14:31
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You do not use yield return anywhere in your Coroutine. This will cause your coroutine to run all iterations in the same frame.
From the Scripting documentation:
// every 2 seconds perform the print()
private IEnumerator WaitAndPrint(float waitTime)
{
while (true)
{
yield return new WaitForSeconds(waitTime);
print("WaitAndPrint " + Time.time);
}
}
Or you can use yield return null to pass the coroutine onto the next frame:
private IEnumerator YourDialogCoroutine()
{
bool finished = false;
while (!finished)
{
If(Input.GetKeyDown("Z"))
{
Debug.Log("Ending loop!");
finished = true;
}
yield return null;
}
}
Sorry, I didn't quite get that. Could you be more specific?
– Everton Colombo
Nov 15 '18 at 15:11
In the documentation for Coroutines, you have to use the statementyield returnand eithernullor something likeWaitForSeconds(float seconds). I would review the documentation in this case since you are missing this statement
– Eliasar
Nov 15 '18 at 15:13
Actually there are severalyield returns...
– Thomas Hilbert
Nov 15 '18 at 15:14
Coroutines will process all the information within a single frame (stackoverflow.com/a/32469037/1299146). Once your code falls through your foreach loop, there is noyield return nullat the end of your do-while.
– Eliasar
Nov 15 '18 at 15:22
so, i'd have to add a yield return null at the end of the do while?
– Everton Colombo
Nov 15 '18 at 15:24
|
show 6 more comments
You do not use yield return anywhere in your Coroutine. This will cause your coroutine to run all iterations in the same frame.
From the Scripting documentation:
// every 2 seconds perform the print()
private IEnumerator WaitAndPrint(float waitTime)
{
while (true)
{
yield return new WaitForSeconds(waitTime);
print("WaitAndPrint " + Time.time);
}
}
Or you can use yield return null to pass the coroutine onto the next frame:
private IEnumerator YourDialogCoroutine()
{
bool finished = false;
while (!finished)
{
If(Input.GetKeyDown("Z"))
{
Debug.Log("Ending loop!");
finished = true;
}
yield return null;
}
}
Sorry, I didn't quite get that. Could you be more specific?
– Everton Colombo
Nov 15 '18 at 15:11
In the documentation for Coroutines, you have to use the statementyield returnand eithernullor something likeWaitForSeconds(float seconds). I would review the documentation in this case since you are missing this statement
– Eliasar
Nov 15 '18 at 15:13
Actually there are severalyield returns...
– Thomas Hilbert
Nov 15 '18 at 15:14
Coroutines will process all the information within a single frame (stackoverflow.com/a/32469037/1299146). Once your code falls through your foreach loop, there is noyield return nullat the end of your do-while.
– Eliasar
Nov 15 '18 at 15:22
so, i'd have to add a yield return null at the end of the do while?
– Everton Colombo
Nov 15 '18 at 15:24
|
show 6 more comments
You do not use yield return anywhere in your Coroutine. This will cause your coroutine to run all iterations in the same frame.
From the Scripting documentation:
// every 2 seconds perform the print()
private IEnumerator WaitAndPrint(float waitTime)
{
while (true)
{
yield return new WaitForSeconds(waitTime);
print("WaitAndPrint " + Time.time);
}
}
Or you can use yield return null to pass the coroutine onto the next frame:
private IEnumerator YourDialogCoroutine()
{
bool finished = false;
while (!finished)
{
If(Input.GetKeyDown("Z"))
{
Debug.Log("Ending loop!");
finished = true;
}
yield return null;
}
}
You do not use yield return anywhere in your Coroutine. This will cause your coroutine to run all iterations in the same frame.
From the Scripting documentation:
// every 2 seconds perform the print()
private IEnumerator WaitAndPrint(float waitTime)
{
while (true)
{
yield return new WaitForSeconds(waitTime);
print("WaitAndPrint " + Time.time);
}
}
Or you can use yield return null to pass the coroutine onto the next frame:
private IEnumerator YourDialogCoroutine()
{
bool finished = false;
while (!finished)
{
If(Input.GetKeyDown("Z"))
{
Debug.Log("Ending loop!");
finished = true;
}
yield return null;
}
}
edited Nov 15 '18 at 15:30
answered Nov 15 '18 at 15:02
EliasarEliasar
759618
759618
Sorry, I didn't quite get that. Could you be more specific?
– Everton Colombo
Nov 15 '18 at 15:11
In the documentation for Coroutines, you have to use the statementyield returnand eithernullor something likeWaitForSeconds(float seconds). I would review the documentation in this case since you are missing this statement
– Eliasar
Nov 15 '18 at 15:13
Actually there are severalyield returns...
– Thomas Hilbert
Nov 15 '18 at 15:14
Coroutines will process all the information within a single frame (stackoverflow.com/a/32469037/1299146). Once your code falls through your foreach loop, there is noyield return nullat the end of your do-while.
– Eliasar
Nov 15 '18 at 15:22
so, i'd have to add a yield return null at the end of the do while?
– Everton Colombo
Nov 15 '18 at 15:24
|
show 6 more comments
Sorry, I didn't quite get that. Could you be more specific?
– Everton Colombo
Nov 15 '18 at 15:11
In the documentation for Coroutines, you have to use the statementyield returnand eithernullor something likeWaitForSeconds(float seconds). I would review the documentation in this case since you are missing this statement
– Eliasar
Nov 15 '18 at 15:13
Actually there are severalyield returns...
– Thomas Hilbert
Nov 15 '18 at 15:14
Coroutines will process all the information within a single frame (stackoverflow.com/a/32469037/1299146). Once your code falls through your foreach loop, there is noyield return nullat the end of your do-while.
– Eliasar
Nov 15 '18 at 15:22
so, i'd have to add a yield return null at the end of the do while?
– Everton Colombo
Nov 15 '18 at 15:24
Sorry, I didn't quite get that. Could you be more specific?
– Everton Colombo
Nov 15 '18 at 15:11
Sorry, I didn't quite get that. Could you be more specific?
– Everton Colombo
Nov 15 '18 at 15:11
In the documentation for Coroutines, you have to use the statement
yield return and either null or something like WaitForSeconds(float seconds). I would review the documentation in this case since you are missing this statement– Eliasar
Nov 15 '18 at 15:13
In the documentation for Coroutines, you have to use the statement
yield return and either null or something like WaitForSeconds(float seconds). I would review the documentation in this case since you are missing this statement– Eliasar
Nov 15 '18 at 15:13
Actually there are several
yield returns...– Thomas Hilbert
Nov 15 '18 at 15:14
Actually there are several
yield returns...– Thomas Hilbert
Nov 15 '18 at 15:14
Coroutines will process all the information within a single frame (stackoverflow.com/a/32469037/1299146). Once your code falls through your foreach loop, there is no
yield return null at the end of your do-while.– Eliasar
Nov 15 '18 at 15:22
Coroutines will process all the information within a single frame (stackoverflow.com/a/32469037/1299146). Once your code falls through your foreach loop, there is no
yield return null at the end of your do-while.– Eliasar
Nov 15 '18 at 15:22
so, i'd have to add a yield return null at the end of the do while?
– Everton Colombo
Nov 15 '18 at 15:24
so, i'd have to add a yield return null at the end of the do while?
– Everton Colombo
Nov 15 '18 at 15:24
|
show 6 more comments
From what I see....
In English: As soon as dialogIndex is not equal to dialogFiles.length minus one your script crashes.
Once this:
while (dialogIndex != dialogFiles.Length - 1);
is true, it enters into a endless loop. There are no directions of what to do once dialogFiles.Length -1 no longer is equal to dialogIndex.
Not sure what you are trying to accomplish with the final line of code there, but neither is the computer and it just waits for instructions once those conditions are met....forever.
It needs to be
while (dialogIndex != dialogFiles.Length - 1); {
Do Something;
provide Action To Eventually escape this loop (make dialogIndex = dialogFiles.Length - 1)
}
As for as the comment goes, you can do StartCoroutine(type()); or StartCoroutine("type"); That's fine.
that last line of code (while(dialogIndex != dialogFiles.Lenght - 1)) is actually part of a do while loop. And, while waiting for an answer, i've also found out that the line of code causing the problem is actually the while(!finished) loop, I still don't know why though.
– Everton Colombo
Nov 15 '18 at 14:25
just to make it clear, the goal of this script is to type out dialogFiles[dialogIndex].dialogText whit a type writer effect while also having the possibility to speed up the typing process by pressing 'z' on the keyboard and, once all the text was typed out, pressing 'z' again would lead to increasing dialogIndex by one.
– Everton Colombo
Nov 15 '18 at 14:31
add a comment |
From what I see....
In English: As soon as dialogIndex is not equal to dialogFiles.length minus one your script crashes.
Once this:
while (dialogIndex != dialogFiles.Length - 1);
is true, it enters into a endless loop. There are no directions of what to do once dialogFiles.Length -1 no longer is equal to dialogIndex.
Not sure what you are trying to accomplish with the final line of code there, but neither is the computer and it just waits for instructions once those conditions are met....forever.
It needs to be
while (dialogIndex != dialogFiles.Length - 1); {
Do Something;
provide Action To Eventually escape this loop (make dialogIndex = dialogFiles.Length - 1)
}
As for as the comment goes, you can do StartCoroutine(type()); or StartCoroutine("type"); That's fine.
that last line of code (while(dialogIndex != dialogFiles.Lenght - 1)) is actually part of a do while loop. And, while waiting for an answer, i've also found out that the line of code causing the problem is actually the while(!finished) loop, I still don't know why though.
– Everton Colombo
Nov 15 '18 at 14:25
just to make it clear, the goal of this script is to type out dialogFiles[dialogIndex].dialogText whit a type writer effect while also having the possibility to speed up the typing process by pressing 'z' on the keyboard and, once all the text was typed out, pressing 'z' again would lead to increasing dialogIndex by one.
– Everton Colombo
Nov 15 '18 at 14:31
add a comment |
From what I see....
In English: As soon as dialogIndex is not equal to dialogFiles.length minus one your script crashes.
Once this:
while (dialogIndex != dialogFiles.Length - 1);
is true, it enters into a endless loop. There are no directions of what to do once dialogFiles.Length -1 no longer is equal to dialogIndex.
Not sure what you are trying to accomplish with the final line of code there, but neither is the computer and it just waits for instructions once those conditions are met....forever.
It needs to be
while (dialogIndex != dialogFiles.Length - 1); {
Do Something;
provide Action To Eventually escape this loop (make dialogIndex = dialogFiles.Length - 1)
}
As for as the comment goes, you can do StartCoroutine(type()); or StartCoroutine("type"); That's fine.
From what I see....
In English: As soon as dialogIndex is not equal to dialogFiles.length minus one your script crashes.
Once this:
while (dialogIndex != dialogFiles.Length - 1);
is true, it enters into a endless loop. There are no directions of what to do once dialogFiles.Length -1 no longer is equal to dialogIndex.
Not sure what you are trying to accomplish with the final line of code there, but neither is the computer and it just waits for instructions once those conditions are met....forever.
It needs to be
while (dialogIndex != dialogFiles.Length - 1); {
Do Something;
provide Action To Eventually escape this loop (make dialogIndex = dialogFiles.Length - 1)
}
As for as the comment goes, you can do StartCoroutine(type()); or StartCoroutine("type"); That's fine.
answered Nov 15 '18 at 14:06
Brian GreenBrian Green
412
412
that last line of code (while(dialogIndex != dialogFiles.Lenght - 1)) is actually part of a do while loop. And, while waiting for an answer, i've also found out that the line of code causing the problem is actually the while(!finished) loop, I still don't know why though.
– Everton Colombo
Nov 15 '18 at 14:25
just to make it clear, the goal of this script is to type out dialogFiles[dialogIndex].dialogText whit a type writer effect while also having the possibility to speed up the typing process by pressing 'z' on the keyboard and, once all the text was typed out, pressing 'z' again would lead to increasing dialogIndex by one.
– Everton Colombo
Nov 15 '18 at 14:31
add a comment |
that last line of code (while(dialogIndex != dialogFiles.Lenght - 1)) is actually part of a do while loop. And, while waiting for an answer, i've also found out that the line of code causing the problem is actually the while(!finished) loop, I still don't know why though.
– Everton Colombo
Nov 15 '18 at 14:25
just to make it clear, the goal of this script is to type out dialogFiles[dialogIndex].dialogText whit a type writer effect while also having the possibility to speed up the typing process by pressing 'z' on the keyboard and, once all the text was typed out, pressing 'z' again would lead to increasing dialogIndex by one.
– Everton Colombo
Nov 15 '18 at 14:31
that last line of code (while(dialogIndex != dialogFiles.Lenght - 1)) is actually part of a do while loop. And, while waiting for an answer, i've also found out that the line of code causing the problem is actually the while(!finished) loop, I still don't know why though.
– Everton Colombo
Nov 15 '18 at 14:25
that last line of code (while(dialogIndex != dialogFiles.Lenght - 1)) is actually part of a do while loop. And, while waiting for an answer, i've also found out that the line of code causing the problem is actually the while(!finished) loop, I still don't know why though.
– Everton Colombo
Nov 15 '18 at 14:25
just to make it clear, the goal of this script is to type out dialogFiles[dialogIndex].dialogText whit a type writer effect while also having the possibility to speed up the typing process by pressing 'z' on the keyboard and, once all the text was typed out, pressing 'z' again would lead to increasing dialogIndex by one.
– Everton Colombo
Nov 15 '18 at 14:31
just to make it clear, the goal of this script is to type out dialogFiles[dialogIndex].dialogText whit a type writer effect while also having the possibility to speed up the typing process by pressing 'z' on the keyboard and, once all the text was typed out, pressing 'z' again would lead to increasing dialogIndex by one.
– Everton Colombo
Nov 15 '18 at 14:31
add a comment |
I'm not a Unity expert but I don't think you want to call
type()(great name for a method btw) when you start the coroutine. I think you pass it the method info:StartCoroutine(type);– Crowcoder
Nov 15 '18 at 13:52