Does anybody perhaps have any clues as to why this from the docs is working fine (script attached to cube):
#pragma strict
var newTexture = "http://my.site/my.png";
function Start () {
}
function Update () {
transform.Rotate(0, 5*Time.deltaTime, 0);
if(Input.GetKey ("1") )
{
switchTexture();
}
}
function switchTexture() {
var www : WWW = new WWW (newTexture);
yield www;
renderer.material.mainTexture = www.texture;
}
But this (attached to the FPS camera) gives me a could not connect to host error:
#pragma strict
function Start () {
}
var metalTexture = "http://my.site/mypic.png";
function doTextureGUI(){
Debug.Log("Loading texture from the web");
var www : WWW = new WWW (metalTexture);
yield www;
var cube = GameObject.Find("PreviewCube");
cube.renderer.material.mainTexture = www.texture;
}
function OnGUI() {
if (GUI.Button(Rect(10,70,150,60),"Switch Texture"))
{
doTextureGUI();
}
}
function Update () {
}
I am using the latest Unity Pro and I have set my build target to Windows Standalone.
Any help much appreciated. This is my first Unity script!