- Home /
Unity 2017 www bug?
Hello, I'm just wondering if the WWW class got some trouble with the error handlings right now? I've got a little snippet that works under Unity 5, but as soon as I test it under unity 2017 I get errors.
Enumerator Start () {
//Creating user table
string createJsonLink = "my url wich contains a php file that create a json file";
yield return StartCoroutine(loadingTable(createJsonLink));
}
IEnumerator loadingTable(string createLink){
print("create link:"+createLink);
check = false;
www = new WWW(createLink);
//Load the data and yield (wait) till it's ready before we continue executing the rest of this method.
yield return www;
if (!string.IsNullOrEmpty(www.error))
{
//Sucessfully loaded and executed the php file
print("loaded OK");
}
else
{
Debug.Log("ERROR: " + www.error);
}
}
this outputs :
create link:the url link correctly passed
ERROR:
As if there was no returned message or anything. I've see that some people got similar trouble and changed the usual if (www.error == null) by if (!string.IsNullOrEmpty(www.error)) which i did too, but without success.
Does some other people get this problem too ?
I am having the same issue. Worked in 5.6, but not in 2017. Don't have an answer yet, but just wanted to let you know you aren't crazy.
thanks, I was starting to doubt of my mental health too :)
Hello,
I also have problems with WWW, I just switched to 2017 , and all my WWW are returning "$$anonymous$$ Error" now... and I am only accessing locals files :
string url = "file:///" + folder_name + "/notes.mid";
WWW midiFile = new WWW(url);
while (!midiFile.isDone)
{
}
if (!string.IsNullOrEmpty(midiFile.error))
{
GameController.Log("Can't Load Song: " + folder_name);
return false;
}
I am on Windows, it failed in Editor mode also. Regards, Seb
It's impossible that this has worked on any previous version of Unity. I work with Unity since version 2.6 and i can guarantee, nothing has changed in that regard.
Also using a while loop like this is dangerous and not recommended. It will completely fail on WebGL builds as they are "single threaded". So isDone has no chance to become true. Use a coroutine ins$$anonymous$$d.
btw. What you posted is not an answer to the question. I'll convert it into a comment.
Can you please stop expecting bugs behind every problem? 99.9% of all problems we deal with here on UA are the reason of a "user error". And that's exactly the case here as well. -.-
Well, I had this problem since the launch of Unity2017, post some questions about it -At start, I never think that it was a bug-, wanted to know what have changed since the 2017 launch , In my precedent version i just checked if there was a www.error (not a check on string), then after sawing some posts that telling that you have (since unity 2017) to check if the string message in the error was empty, I changed checking if the string was empty or not and Then I made the mistake of logic reverse :(
But as no one ever answer to it in month, just people complaining about the fact that since Unity2017 their code start to fails too, that's when I start doubting and wrote this question asking if it was a bug now.
Thanks anyway for pointing that out
You don't have to check if there's an error, but if there's an error your code will break since you can't access www.text / www.texture / ... if there was an error. So it's common practise to check if the request was successful.
Nothing has changed in the WWW behaviour in the last 5 years or more. Where did you read that there was a change in 2017? Do you have a link?
Unfortunately there are quite a few people here on UA which base their answers soley on assumptions and personal opinion rather than empirical research and knowledge. I do make assumptions as well, but i always make clear that it is an assumption. Though i only make assumptions if i'm very sure that they are correct. If i do not know the answer i either test it myself before answering or just do not answer. It doesn't help anyone to spread wrong information.
Answer by Bunny83 · Aug 26, 2017 at 04:55 AM
Uhm you have reversed your logic. www.error will be null or empty when there is no error. Currently you check the opposite. You print error when the error message is null or empty. That's why the debug log shows, well, nothing. That's because everything just worked fine.
You have to use:
if (string.IsNullOrEmpty(www.error))
{
//Sucessfully loaded and executed the php file
print("loaded OK");
}
else
{
Debug.Log("ERROR: " + www.error);
}
Note that i removed the "not" from the if condition.
Your answer
![](https://koobas.hobune.stream/wayback/20220612133052im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
WWW.text length of a string in Unity3d populated ? 1 Answer
What has changed in the WWW class? What am I doing wrong? 0 Answers
Help searching google! 1 Answer
Downloading text from web gives html code. 2 Answers
Performance problem in web request upgrading from Unity 5.3.4f1 to Unity 5.6.4f1 0 Answers