I cant get WWW to work from the webplayer…
it works from the editor, from a standalone for mac, but not from any browser I’ve tested. I must be doing something stupid…
are there security settings in the browser to worry about? I am behind a router, which is probably using some version of NAT, but from the same machine, the standalone works, the web player doesnt.
here is a simple test app I created. am I doing something wrong there?
thanks!
using UnityEngine;
using System.Collections;
public class NetTest : MonoBehaviour
{
public string message = "ready to run test";
private Rect centerRect = new Rect(Screen.width / 4, Screen.height / 4, Screen.width / 2, Screen.height / 2);
void OnGUI()
{
GUILayout.BeginArea(centerRect);
GUILayout.TextArea(message);
if (GUILayout.Button("run test"))
{
StartCoroutine("ping");
}
if (GUILayout.Button("kill coroutine"))
{
StopCoroutine("ping");
}
GUILayout.EndArea();
}
IEnumerator ping()
{
string pingURL = "www.google.com";
WWW httpCall = new WWW(pingURL);
while (!httpCall.isDone)
{
message = "waiting for ping";
yield return new WaitForSeconds(1);
}
if (httpCall.error != null)
{
message = "failed! error message= " + httpCall.error;
}
else
{
string response = httpCall.data;
if (response.Length > 0)//assume for now that getting back anything counts as success...
{
message = "ping succeeded";
}
}
}
}