- Home /
Question by
SARWAN · Mar 26, 2014 at 09:20 AM ·
ienumeratoruntiy3d
Return statement in IEnumerator Unity C#
Hi,
I have problem in IEunmerator function Unity C#.
In the following script I want to return the function if the the string is null. But, using IEnumerator will not allow me to put return statement inside of it.
IEnumerator DownloadData ()
{
WWW download = new WWW (URL, form);
yield return download;
XMLValue.PHPValues= this.gameObject;
if (!string.IsNullOrEmpty(download.error))
{
ErrorPopup("Please check your internet connection.");
return;
}
}
If i use
yield return 0;
(or)
yield return null;
will execute the lines after this line. But, How could i return control from the function??
Comment
Best Answer
Answer by frarees · Mar 26, 2014 at 09:23 AM
Use yield break;
IEnumerator DownloadData ()
{
WWW download = new WWW (URL, form);
yield return download;
XMLValue.PHPValues= this.gameObject;
if (!string.IsNullOrEmpty(download.error))
{
ErrorPopup("Please check your internet connection.");
yield break;
}
}
Your answer
Follow this Question
Related Questions
IEnumerator problems in C# 2 Answers
c# 2D array error: need Help! 1 Answer
Can we edit code of objects in hierarchy directly? 1 Answer
Turn bool on/off x time every few seconds in coroutine 2 Answers