this is for a chistmas present so it’s kinda pressing…
I just want to read text from an url. html or json and always get “cannot connect to destination host”, tried this on multiple devices with firewall off. If I would get a connection I could acces the data via www.text right?
everyone on the web seems to do it that way, but it won’t work here
I am going crazy…
using UnityEngine;
using System.Collections;
public class ExampleScript : MonoBehaviour
{
public string url = "http%3A%2F%2Fwww.brainjar.com%2Fjava%2Fhost%2Ftest.html";
IEnumerator Start()
{
using (WWW www = new WWW(url))
{
yield return www;
if (!string.IsNullOrEmpty(www.error))
Debug.Log(www.error);
}
}
}
Yes, I saw that comment on the doc page, but I think that refers only to special characters. For instance, if you look at the ‘escapeURL’ and ‘unescapeURL’ methods, they show an example … something like “Fish & Chips” and how it gets converted to something like “Fish+%38+Chips” (forget the exact hex value).
When you say won’t even try to connect, just curious how do you know? From your code there is no way to tell ? (well, if you get no error).
Not true and you misunderstood what the escaping means.
The URL you pasted here is completely valid and would work!
The part about %-escaping applies to characters that are not part of URI syntax like spaces. The slashes that are part of URL syntax should remain slashes.
Yeah, don’t escape all the slashes, there is no need. And you can always pass your link to Unity - Scripting API: WWW.EscapeURL to let it convert for you. But just use the link straight up, you’ll be fine.