I need to apply texture files from an online location (same server as the swf) to objects in the scene, but I’ve had no luck at all with WWW class. Here is the code I’m testing:
#pragma strict
var url = "http://myserver.com/texture.jpg";
var plane : GameObject;
plane = GameObject.Find( "Plane" );
var www : WWW;
var isDone = "Texture Loading . . .";
function Start ()
{
www = new WWW (url);
}
function OnGUI ()
{
if (!www.isDone)
{
GUI.Label ( Rect (23, 23, 100, 30), isDone );
}
else
{
if (GUI.Button (Rect (10,10, 100, 50), "Apply Texture"))
{
plane.renderer.material.mainTexture = www.texture;
}
}
}
It works in the editor. When I place a test build online, the Apply Texture button has no effect.
Am I doing something wrong? If not, is there a workaround? Thanks.