- Home /
Is web site available from within a scene
I have been searching the Q&A to get an answer but everything I look it either costs money (which, being out of work I currently don't have) or doesn't work in all situations (i.e. public vs private).
What I'm trying to accomplish is to see if a single domain can be reached within Unity by means of a single function.
I simply need a boolean returned but I'm finding it hard to determine which function (if there is one) I can use.
I know you can use "Ping" but this can return true if a public hot spot is available, even if you don't have actual "access" to it.
What I'm looking for is something like...
public bool webSiteReachable(string webSite) {
TestConnection result = new TestConnection(webSite);
return(result.isAccessible);
}
What I'd like to know is, what function can I use as "TestConnection"?
I hope I've explained myself clearly enough and any help, as always, is greatly appreciated.
Answer by Diablo404 · Oct 24, 2014 at 09:47 AM
What you're searching is probably WWW ( http://docs.unity3d.com/ScriptReference/WWW.html )
And you could do:
bool isRecheable = false;
public IEnumerator webSiteReachable(string webSite)
{
WWW www = new WWW(url);
yield return www;
if (String.IsNullOrEmpty(www.error))
{
isRecheable = true;
}
else
{
isRecheable = false;
}
}
But as you can see your function will have to be IEnumerator type so you'll have to make a global bool OR make a callback at the end of the function.
Hmm. Thanks for that. I must have totally misread the docs on this one because I looked at it and thought it wasn't sufficient. Perhaps I should read it again.
Your answer
![](https://koobas.hobune.stream/wayback/20220613165832im_/https://answers.unity.com/themes/thub/images/avi.jpg)