- Home /
Load file from Local Server, getting malformed url error
I have a local server setup at http://localhost:8000. I can verify it is working properly through my browser.
Trying to load a text file from that directory as such:
public string url = "http://localhost:8000/userqueue.json";
IEnumerator Start()
{
WWW www = new WWW(url);
yield return www;
print(www.error);
}
I get a url malformed error from that and no data. Any suggestions?
Thank you!
Answer by pajamajama · Sep 03, 2014 at 07:52 AM
Solved! ooh baby.
Despite being initialized in code, because the url string is public it was defaulting to a blank string in my inspector.
Is this a bug? Ints seem to initialize properly in this same manner.
No, its not a bug. Since it was blank in inspector Unity uses the value from the inspector since that gets serialized and not the default value from the script.
It's strange to me because I never set it blank in the inspector.
When I create a public int and initialize it in code, the inspector defaults to the value in code. I'm just not sure why strings would behave differently and default to blank.
It happens if you change the value in the inspector and then save your scene then your new value will supersede the previous one. In this case it is your blank value.
Your answer
Follow this Question
Related Questions
Server Based High Score - issues with adding new score 1 Answer
Half image download from the server ? 0 Answers
'Online Game' - Same Wifi 1 Answer
upload png receives multiple results from server 0 Answers
Web Service Call Confirmation 0 Answers